摘要:
列表生成器生成1-101的数a=list(range(1,101))print(a)a=[i for i in range(1,101)]print(a)展示所有文件import osa=[d for d in os.listdir('.')]print(a) 将列表里的字符串变成小写 列表生成式L 阅读全文
摘要:
函数定义def hello(): # print(123) return 123print(hello())输出最大值与最小值def get_max_min(lists): max=lists[0] min=lists[0] for i in lists: if max<i: max=i if mi 阅读全文
摘要:
元组a=(1,2,3,4,5)print(type(a))for i in a: print(i)字典无序 键名不能重复,不可以是可变元素dicts={'hello':[1,2,3],123:'nohao','s':{'ni':'hao'}}print(dicts['hello'])查print(d 阅读全文
摘要:
购物车car=[]lists=[['水果',['梨','苹果']],['日用百货',['卫生纸','毛巾']]]flag='t'while 1: if flag=='f': print(car) break n = 0 for a,b in lists: n=n+1 print(n,a) m=0 n 阅读全文