【发布时间】:2013-12-09 16:48:03
【问题描述】:
我想创建一个 .arff 文件,其中显示我的 python 代码中最有用的 10 个单词。格式应该是这样的。
@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? -
有人可以帮我吗?