所以我合併兩個文件,並輸出第三文件NameError:名稱「」沒有定義
我得到的錯誤
Traceback (most recent call last):
File "summarize.py", line 124, in <module>
train_data = set(document3)
NameError: name 'document3' is not defined
這是我做了什麼:
代碼:
filenames = ["/home/mustafa/data/combinedfile.txt", "/home/mustafa/data/sentences.txt"]
with open("document3", "wb") as outfile:
for fname in filenames:
with open(fname) as infile:
outfile.write(infile.read())
train_data = set(document3)
我在做什麼錯?
很簡單,你沒有名爲'document3'的變量。 –
林沒有pythonist,但它看起來像你忘記了一些「」在文檔3周圍 –