室友之前給的代碼會出錯,說整數不能迭代??不知道什么意思,找了個百度回答,解決了編碼問題,還解決了字符和數值不能連接的問題(數值化成字符),但是最后是把字典和字典的值打印出來了,不是保存起來了
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import os
write_file = os.getcwd() + '\dit.txt'
print write_file
output = open(write_file,'w')
for i in dict:
print i,bytes(dict[i])
write_str = str(i) + ' ' + bytes(dict[i]) + '\n'
output.write(write_str)
output.close()

啊,這個人是直接保存了一個文件
最后會顯示文件路徑,

右側也能看到
https://jingyan.baidu.com/article/f54ae2fcd9a2b91e93b84946.html
把帶空格的txt導入excel,不要直接復制粘貼,要從數據-導入外部數據中導入,以空格為分隔符

