摘要: 1 #author F 2 import time 3 #面向对象 : 类 --->class 4 #面向过程 : 过程-->def 5 #函数式编程 : 函数-->def 6 7 #定义函数 8 def func1(): 9 """testing""" 10 print("in the func1") 11 return 0 12 #定义过程... 阅读全文
posted @ 2017-06-13 18:41 Bird_getUpEarly 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 1 #author F 2 #字符编码 3 4 import sys 5 print(sys.getdefaultencoding()) #打印默认编码 6 ''' 7 #python2中编码转换 8 9 s = "你好" 10 s_to_unicode = s.decode("utf-8") 11 print(s_to_unicode) 12 s_to_gbk = s_t... 阅读全文
posted @ 2017-06-13 15:15 Bird_getUpEarly 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 1 #author F 2 3 #with语句 4 5 with open("test", "r", encoding="utf-8") as f: #with代码块执行完毕时会自动关闭并释放资源 6 for line in f: 7 print(line) 8 9 with open("test", "r", encoding="utf-8"... 阅读全文
posted @ 2017-06-13 11:27 Bird_getUpEarly 阅读(1879) 评论(0) 推荐(0) 编辑
摘要: 1 #author F 2 3 import sys,time 4 5 6 f = open("file", "r", encoding="utf-8") 7 8 print(f.tell()) 9 print(f.readline().rstrip()) 10 print(f.read(5)) 11 print(f.tell()) 12 print(f.read())... 阅读全文
posted @ 2017-06-13 10:32 Bird_getUpEarly 阅读(166) 评论(0) 推荐(0) 编辑