我可以帮我处理这段代码吗,现在我得到的“test2”与“test”一样,如果我测试的是字符串,它运行良好,但作为列表,它无法正常工作 punc = set(string.punctuation) test=[" course content good though textbook badly written.not got energy though seems good union.it distance course i'm sure facilities.n/an/ain last year offer poor terms academic personal. seems un become overwhelmed trying become run"]test2 = ''.join(w for w in test if w not in punc) print(test2)我想删除所有标点符号
3 回答

qq_遁去的一_1
TA贡献1725条经验 获得超7个赞
由于 test 是一个列表,'for w in test' 将返回列表的第一项,即完整的字符串。因此,您需要访问 'w' 的所有项目以实际测试字符串的所有单个字符。
添加回答
举报
0/150
提交
取消