我试图从WordNet中提取所有附属形容词语法集,并将它们保存到文本文件中。注意,附属形容词在synset名称中表示为“s”,例如“(fantactic.s.02)”。以下是我的代码:
def extract_sat_adjectives():
sat_adj_counter = 0
sat_adjectives = []
for i in wn.all_synsets():
if i.pos() in ['s']:
sat_adj_counter +=1
sat_adjectives = sat_adjectives + [i.name()]
fo = open("C:\\Users\\Nora\\Desktop\\satellite_adjectives.txt", "wb")
for x in sat_adjectives:
fo.write("%s\n" % x)
fo.close()
extract_sat_adjectives()
我得到的错误是:
^{pr2}$如何将形容词保存到文本文件中?提前谢谢。在
错误与编码错误和
str()
的组合有关更改为:
^{pr2}$相关问题 更多 >
编程相关推荐