Python--高阶内置函数、处理错误异常

Python--高阶内置函数、处理错误异常

以自定义PE_ratio为例写文档def PE(Price,Earning): """Calculate PE ratio""" PE=Price/Earning return print(PE)--------------------PE.__doc__'Calculate PE ratio'lambda表达式创...

编程语言 2019-02-09 PM 141次 0条
Python--推导式、函数、自定义函数

Python--推导式、函数、自定义函数

列表推导式number_list = [number for number in range(1, 7)]print(number_list)------------------[1, 2, 3, 4, 5, 6]列表推导式加条件语句单ifnumber_list = [number for number in range(1, 7) i...

编程语言 2019-01-30 PM 127次 0条
Python--迭代

Python--迭代

字典迭代names = {'Mary Wang': 'She is very cute', 'William Liu': 'He is very handsome', 'Tom Zhao': 'He is a little bit shy', 'Jary Qian': 'He is very rich'}for key, value in na...

编程语言 2019-01-29 PM 118次 0条
Python--控制流

Python--控制流

控制流if语句if 判断条件:game = 1000money = 100000if game<2000: game+=1000 money-=1000print('You have '+str(game)+'RMB in your game,' + 'you have '+str(money)+'RMB in your money!')You have 2000...

编程语言 2019-01-27 PM 139次 0条
Python--字典、赋值符号的辨析、复合数据结构

Python--字典、赋值符号的辨析、复合数据结构

字典结构--字典名={字:解释,…}查字典--print(字典名[字])>>> names={'Tom':'Tom is very tall','William':'William is very handsome'}>>> names{'Tom': 'Tom is very tall', 'William': 'William is very hands...

编程语言 2019-01-24 PM 194次 2条
Python--元组及元组解包、集合

Python--元组及元组解包、集合

元组和元组解包tuple元组名=( , )>>> place=(1,2)>>> print('Longitude:',place[0])Longitude: 1>>> print('Latitude:',place[1])Latitude: 2元组解包--批量数据批量赋值>>> dimensions=1,2,3>&...

编程语言 2019-01-22 PM 152次 0条