['this/n', 'is/n', 'a/n', 'list/n', 'of/n', 'words/n']
然后使用条带功能,将其转换为:
['this', 'is', 'a', 'list', 'of', 'words']
我以为我写的东西会起作用,但我一直都会收到错误说:
“‘list’ object has no attribute ‘strip'”
这是我试过的代码:
strip_list = []
for lengths in range(1,20):
strip_list.append(0) #longest word in the text file is 20 characters long
for a in lines:
strip_list.append(lines[a].strip())
本文由 投稿者 创作,文章地址:https://blog.isoyu.com/archives/python-congzifuchuanliebiaodeyuansuzhongshanchuweisuihuan.html
采用知识共享署名4.0 国际许可协议进行许可。除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为:9 月 19, 2019 at 04:32 下午