摘要: 笨方法系列name=input("please input your name :")age=input("please input your age:")# print("you name is %s,you age is %d"%(name,age))print(f"you name is {n 阅读全文
posted @ 2020-08-03 23:48 质料 阅读(150) 评论(0) 推荐(0)
摘要: 1.列举布尔值为false的例子 0 False “” [] {} () None 2.列举将3和7整除的100以内的数 def func(start,end,a=0,b=0): if start==end: return a,b if start%3 and start%7 ==0: a=a+1 阅读全文
posted @ 2020-07-30 05:16 质料 阅读(126) 评论(0) 推荐(0)
摘要: 恢复内容开始 迭代器 实际就是调用next方法 使被处理对象通过__iter__在内部建立一个对应的next方法 f=open("text.txt","r+")iter_f=f.__iter__()print(iter_f.__next__(),end="")print(iter_f.__next_ 阅读全文
posted @ 2020-07-26 11:25 质料 阅读(103) 评论(0) 推荐(0)
摘要: import timeperson_list = ["chb", "wmq", "xxy", "lyp", "wzq"]def ask_way(person_list): print("-" * 60) if len(person_list)== 0 : return"no one can help 阅读全文
posted @ 2020-06-03 23:41 质料 阅读(109) 评论(0) 推荐(0)
摘要: 一、函数的意义 1.代码组织结构不清晰 2.遇到重复的功能 只能重新写代码 代码复用性差 3.延展性差 二、函数是什么 是工具,就像生活中的扳手,改锥等等 三、函数的分类 内置函数和自定义函数 四、def(name): """注释“”“” 函数体 形参与实参 形参只有在调用时才分配内存单元 所以形参 阅读全文
posted @ 2020-06-03 18:49 质料 阅读(137) 评论(0) 推荐(0)
摘要: # s=set('hello')# print(s)## s=set(['alex','alex','hello'])# print(s)# s={1,2,3,4,5,6}#添加# s.add('s')# s.add('3')# s.add(3)# print(s)# s.clear()# prin 阅读全文
posted @ 2020-05-06 15:56 质料 阅读(115) 评论(0) 推荐(0)
摘要: msg='i am %s my hobby is %s' % ('chb','coding')print(msg)字符串%s name = 'chb'age = 19msg = 'i am %s my hobby is %d' % (name, age)print(msg) #打印浮点数tpl = 阅读全文
posted @ 2020-05-06 15:31 质料 阅读(135) 评论(0) 推荐(0)
摘要: 集合:数字,列表,字符串,布尔值 索引取值 v = ["ds","dsads",1]print(v[2])切片取值 v = ["ds","dsads",1]print(v[0:2])列表是不连续的 所以列表元素可以进行修改修改: v = ["ds","dsads",1]v[1]=0print(v)删 阅读全文
posted @ 2020-05-01 21:33 质料 阅读(101) 评论(0) 推荐(0)
摘要: 1.空字符串为假 其他为真 0为假 其他为真 li=["dds", "a,","c"]v="_".join(["dds", "a,","c"])print(v)列表的组合for循环 for i in range(100,0,-1): print(i) 阅读全文
posted @ 2020-04-28 21:02 质料 阅读(92) 评论(0) 推荐(0)
摘要: find 从字符串找出对应的子序列 test="chb0420"v=test.find("0",0,3)print(v)输出结果为-1 后面的是开区间 test="chb0420"v=test.find("c",0,3)print(v)输出结果0 前面的是闭区间format格式化 将占位替换 for 阅读全文
posted @ 2020-04-27 13:09 质料 阅读(125) 评论(0) 推荐(0)