1,with可以在写入文件后自动将文件关闭`
with open ('text.txt.', 'w') as f:
f.write('test')
比
f=open('text.txt','w')
f.write('test')
要好
2,format 比 % 要好
3,from collections import Counter
Counter 在计数时特别好用
1,with可以在写入文件后自动将文件关闭`
with open ('text.txt.', 'w') as f:
f.write('test')
比
f=open('text.txt','w')
f.write('test')
要好
2,format 比 % 要好
3,from collections import Counter
Counter 在计数时特别好用