摘要:
在运行一个小脚本时,脚本从一文本文件读取数据,事实上这个文件只有一行'count:2',并取到这个2,将其转成数字。但运行,总是报错。 代码如下: 1 with open('count.txt', 'r') as file: 2 if not file.readline(): 3 pass 4 el 阅读全文
摘要:
在运行一个小脚本时,脚本从一文本文件读取数据,事实上这个文件只有一行'count:2',并取到这个2,将其转成数字。但运行,总是报错。 代码如下: 1 with open('count.txt', 'r') as file: 2 if not file.readline(): 3 pass 4 el 阅读全文
摘要:
pickle 有dump ,dumps ,load,loads等方法。区别在于dumps不会写入到文件。 1 import pickle 2 3 string = ['a', 2341, 'adsf'] 4 5 p_str= pickle.dumps(string) 6 print(p_str) 7 阅读全文
|