摘要: 数据打印到第530行之后出现以下异常,求解! 阅读全文
posted @ 2019-11-15 10:55 mada’sPythonroad 阅读(10675) 评论(4) 推荐(1) 编辑
摘要: import time #时间戳 #计算 print(time.time()) #1591259157.4499538秒 #结构化时间 当地时间 print(time.localtime(1531242343)) t=time.localtime() print(t.tm_year) print(t 阅读全文
posted @ 2020-06-04 16:31 mada’sPythonroad 阅读(108) 评论(0) 推荐(0) 编辑
摘要: #tag一个状态可以标识某种操作,tag=false时,整个循环一起跳出,而不是一层一层跳出#bin文件一般是文件入口,来执行文件,什么都不做,仅作为程序的初始点 #main文件一般与逻辑相关的主函数 导入模块的方式:#1.from web.web1.web3 import cal#2.from w 阅读全文
posted @ 2020-06-04 16:24 mada’sPythonroad 阅读(142) 评论(0) 推荐(0) 编辑
摘要: ---def test(x): # def:定义函数的关键字,test:函数名, x相当于以前函数中的自变量使用函数的好处:1.代码重用2.保持一致性,易于维护3.可扩展性 def test(x): # def:定义函数的关键字,test:函数名, x相当于以前函数中的自变量 ''' 2*x+1 :param x:整形数字 :return: 返回计算结果 ... 阅读全文
posted @ 2019-10-17 17:27 mada’sPythonroad 阅读(139) 评论(0) 推荐(0) 编辑
摘要: tpl = "i am {name}, age {age}, really {name}".format(name="seven", age=18) print(tpl) # i am seven, age 18, really seven 必须一一对应,否则会报错 tpl = "i am {name}, age {age}, really {name}".format(**{"name": ... 阅读全文
posted @ 2019-10-16 21:39 mada’sPythonroad 阅读(170) 评论(0) 推荐(0) 编辑
摘要: msg='i am %s my hobby is %s' % ('lhf','alex') # # %代表标识,固定格式 s代表传入的为字符串,该字符串可接受任何类型 # # %d ,只能接收数字 print(msg) # i am lhf my hobby is alex msg='i am %s my hobby is %s' % ('lhf',1) msg='i am %s my ... 阅读全文
posted @ 2019-10-16 21:38 mada’sPythonroad 阅读(155) 评论(0) 推荐(0) 编辑
摘要: --add()添加 --clear()清空 --copy()复制 --pop() # 集合无序,随机删除 --s.remove() # 指定删除元素,当删除元素不存在时,会报错 --discard() # 删除指定元素,元素不存在时也不报错 阅读全文
posted @ 2019-10-16 10:49 mada’sPythonroad 阅读(127) 评论(0) 推荐(0) 编辑
摘要: # 1.用代码实现:利用下划线将列表的'每一个元素'拼接成字符串 li=['ndfj','dlfj',12434]# 注意是将元素与元素转换为字符串之间用_拼接,而不是将每个字符串进行拼接 li=['ndfj','dlfj',12434] li[2]=str(li[2]) print('_'.join(li) ) # print:ndfj_dlfj_12434 s = '' for i in l... 阅读全文
posted @ 2019-10-14 22:51 mada’sPythonroad 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 一、数字int(..)二、字符串replace/find/join/strip/startswith/split/upper/lower/format tempalte = "i am {name}, age : {age}" v = tempalte.format(name='alex',age= 阅读全文
posted @ 2019-10-13 10:32 mada’sPythonroad 阅读(106) 评论(0) 推荐(0) 编辑
摘要: # 字典# dict 1.fromkeys()根据序列,创建字典,并指定统一的值 v = dict.fromkeys(["k1",123,"999"],123) print(v) {'k1': 123, 123: 123, '999': 123} 2.get()根据Key获取值,key不存在时,可以指定默认值(None) v = dic['k11111'] print(v) NameErro... 阅读全文
posted @ 2019-10-12 22:51 mada’sPythonroad 阅读(246) 评论(0) 推荐(0) 编辑