摘要: 一个记录日志的函数 1 import time 2 def logger(n): 3 time_format = '%Y-%m-%d %X' 4 time_current = time.strftime(time_format) 5 6 with open('日志记录','a') as f: 7 f 阅读全文
posted @ 2019-05-26 22:30 再也不会见 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 示例 浅拷贝 浅拷贝只会拷贝第一层 深拷贝 关键词dir.deepcopy() 阅读全文
posted @ 2019-05-26 22:13 再也不会见 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 集合的作用 1.去重 2.关系测试 集合的访问 集合的删除 集合的关系 阅读全文
posted @ 2019-05-26 22:06 再也不会见 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 作用域 作用范围:built-in>global>enclosing>local 作用范围:global>enclosing>local>built-in L(local)局部作用域 局部变量:包含在def关键字定义的语句块中,即在函数中定义的变量。每当函数被调用时都会创建一个新的局部作用域。Pyt 阅读全文
posted @ 2019-05-26 21:55 再也不会见 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 文件的最基本读写方式 #注意 如果用这种方式打开的文件 一定要使用close()方法关闭文本 虽然python一般情况下会自动关闭文档 Read的一些方法 Wirte的一些方法 r+ w+ a+ with同时管理多个对象 阅读全文
posted @ 2019-05-26 21:45 再也不会见 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 字符串的内置用法: 1 st='hello kitty {name} age is {age}' 2 print(st.count('l')) #统计元素个数 3 print(st.capitalize()) #首字母大写 4 print(st.center(50,'-')) #居中 5 print 阅读全文
posted @ 2019-04-07 00:53 再也不会见 阅读(305) 评论(0) 推荐(0) 编辑
摘要: 还有一些其他用法 元组的创建 1 menu={ 2 '北京':{ 3 '朝阳':{ 4 '国贸':{ 5 'CICC':{}, 6 'HP':{}, 7 '渣打银行':{}, 8 'CCTV':{}, 9 }, 10 '望京':{ 11 '陌陌':{}, 12 '奔驰':{}, 13 '360':{ 阅读全文
posted @ 2019-04-07 00:49 再也不会见 阅读(367) 评论(0) 推荐(0) 编辑
摘要: 1 while True: 2 salary = input("please input your salary:") 3 if salary.isdigit(): 4 salary=int (salary) 5 break 6 else: 7 print("Invalid input! pleas 阅读全文
posted @ 2019-04-07 00:30 再也不会见 阅读(570) 评论(0) 推荐(0) 编辑
摘要: 1 _user="cindy" 2 _pwd="password" 3 passed_authentication = False 4 for i in range (3): 5 username = input("Username=") 6 password = input("Password=" 阅读全文
posted @ 2019-04-07 00:21 再也不会见 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 1 line =9 2 while line >0: 3 #print ("*") 4 tmp =line 5 while tmp >0: 6 print ("#",end="") 7 tmp-=1 8 line -=1 9 print() 10 11 first =0 12 while first 阅读全文
posted @ 2019-04-07 00:14 再也不会见 阅读(172) 评论(0) 推荐(0) 编辑