python基础操作

1。f.string字符串

  它的學名叫作 “Literal String Interpolation”。用法如下:  

>>>defupper(s):
...    returns.upper()
...
>>>stock= 'tsmc'
>>>close= 217.5
>>>f'{stock} price: {close}'
'tsmc price: 217.5'

  还可以:

>>>f'{upper(stock)} price: {close}'
'TSMC price: 217.5'
>>>

2,exit 和finally

try:
    sys.exit(0)
except:
    exit(-1)
    print('die')
finally:
    print('cleanup')

输出

cleanup

 3, None,  False, 空字符串"", 0, 空列表[], 空字典{}, 空元组()都相当于False 

posted @ 2019-04-23 20:20  水中飞云  阅读(85)  评论(0编辑  收藏  举报