TypeError: must be str, not list

こ雲淡風輕ζ 提交于 2019-11-28 14:16:11

Try to this.

sorted_words = ''.join(sorted(scores.items(), reverse=True))

As you dont specify in your post, I dont know which is the separator between values of the tuple, so I added a '\n'. You can change that to ' ' or whatever you want.

final = open("tfidf.csv", "w").write('\n'.join('%s, %s' % x for x in sorted_words))

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!