0
我想創建一個.arff文件,該文件顯示來自我的python代碼的10個最有用的單詞。格式應該是這樣的。試圖使用python創建.arff文件
@attribute pattern1 {yes,no}
@attribute pattern2 {yes,no}
......
.......
@attribute emotion {angry,disgusted,fearful,happy,sad,surprised}
@data
yes, no, no,......, yes, happy
no, no, no,....., no, angry
yes, yes, no,......, yes, sad
每行應包含10個「真」或「假」值的列表,然後是情感。
這是我迄今爲止所寫的內容,但並未按要求顯示。請幫助我。
f = open("emotions.txt", "w")
f.write('''@RELATION Emotions\n
@ATTRIBUTE word{yes,no}
@ATTRIBUTE class {angry,sad,happy,surprised,fearful,disgusted}
@DATA\n''')
for word in varall:
f.write("%s\n" %word)
f.close()
是如何在你的代碼中定義'varall'? – jwodder
作爲列表varall = [] – user2998991
有人可以幫我這個朋友嗎? – user2998991