0
這是我到目前爲止有:寫入鍵,用於分隔文件夾中文本文件的值?
for key,value in spee_dict:
with open(key, 'w+') as f:
f.write(value)
我得到如下:ValueError: too many values to unpack
也許這是因爲我有存儲爲每個鍵值的話數萬。有893個鍵。我怎樣才能解決這個錯誤?
編輯:
Key
和value
都是字符串。
這裏是鍵和值的幾個例子爲spee_dict
:
key value
speech1 we should have gone to the other country a few years ago
speech2 our tax situation is completely fine and revenues are increasing
speech3 ladies and gentlemen, thank you for your attention
...
基本上,我想在我的ü的文件夾中:/驅動器文件,如speech1.txt
,speech2.txt
和speech3.txt
啊對。由於某種原因,這不會寫入我的文件夾在目錄:'U:/ wordfolder' ..它只是在控制檯上運行 – blacksite
我相信OP想要將每個值寫入其自己的文本文件,並使用相應密鑰的文件名。 – pzp
@pzp是的謝謝,我現在才注意到......這是通常的[XY問題](http://xyproblem.info/)咬 – Pynchia