摘要: 首先自定义一个函数,以后只要调用这个函数,就能返回年月日和调用的时间def logger(): #返回年月日和调用的时间 import time time_format='%Y-%m-%d %X ' time_current= time.strftime(time_format ) return t 阅读全文
posted @ 2020-05-12 00:03 逝水无痕L 阅读(1728) 评论(0) 推荐(1)
摘要: 函数式编程中参数使用的学习笔记 def test(x,y,z): print('参数x=',x) print('参数y=',y) print('参数z=',z)test('a','b','z')#实参与形参一一对应'''x= ay= bz= z'''print(' >')test(y= 'a',x= 阅读全文
posted @ 2020-05-11 02:20 逝水无痕L 阅读(480) 评论(0) 推荐(0)
摘要: 集合是无序的,有两个作用:去重:把一个列表变成集合,就自动去重了关系测试:统计两组数据的交集、差集和并集等关系list1=[1,2,3,4,2,3]s=set(list1 ) #保留list1列表,s才是集合print(s,type(s ) )#{1, 2, 3, 4} <class 'set'>l 阅读全文
posted @ 2020-05-06 02:09 逝水无痕L 阅读(286) 评论(0) 推荐(0)
摘要: 字典的常用操作:dictionary={'num1':'a','num2':'b','num3':'c'}print(dictionary ['num2' ])#字典,Python中字典的键之间是无序的,即没有下标,通过键来取值#bdictionary ['num2']='B'print(dicti 阅读全文
posted @ 2020-05-04 03:10 逝水无痕L 阅读(263) 评论(0) 推荐(0)
摘要: 字符中的常用应用笔记:name='jc'print(name.capitalize() ) #capitalize()字符串的首字母大写name ='my name is jc'print(name .count('m') ) #统计字符串中某个参数出现的次数print(name.center(30 阅读全文
posted @ 2020-05-03 01:19 逝水无痕L 阅读(288) 评论(0) 推荐(0)
摘要: 网上看视频时看到的简易购物车要求,先输入拥有的金额,出现供选择的货物列表,输入想要购买的货物编号,最后打印出已购物品清单和余额。fruit_list=[ ('cherry',20), ('apple',8), ('pear',5), ('banana',3), ('strawberry',12)]b 阅读全文
posted @ 2020-05-02 22:32 逝水无痕L 阅读(196) 评论(0) 推荐(0)
摘要: Python中的 isdigit() 是用于检测字符串是否只由数字组成,是则返回Ture,否则返回Flase isdigit()方法语法:str.isdigit() 注:当str是小数时返回Flase 例如: 运行 print(int(1.9) ) # 返回1a=input('输入1.9') # 当 阅读全文
posted @ 2020-05-02 01:44 逝水无痕L 阅读(2134) 评论(0) 推荐(0)
摘要: python中的int()函数 int(x, [base]) 默认base缺省值为10,也就是说不指定base的值时,函数将x按十进制处理 x 可以是数字或字符串,但是base被赋值后 x 的值只能是字符串 int(x):当x是数字时,int(x)就是x向0的方向取最大的整数。 例如: print( 阅读全文
posted @ 2020-05-02 01:00 逝水无痕L 阅读(1033) 评论(0) 推荐(0)