正在尝试从这个列表中删除我正试图插入数据库的\u0141
results=[['The Squid Legion', '0', u'Banda \u0141ysego', '1', ["\nRazer's Clash of the Gods EU #12 - \nChallonge\n"]], ['Romanian eSports', '1', 'Love', '0', ["\nRazer's Clash of the Gods EU #12 - \nChallonge\n"]]]
results =[[x.encode('ascii', 'ignore') for x in l] for l in results]
我得到这个错误:
AttributeError: 'list' object has no attribute 'encode'
“大列表”中的第一个列表本身包含一个列表
["\nRazer's Clash of the Gods EU #12 - \nChallonge\n"]
,它显然没有encode()
方法。所以你的算法是这样的:
您可以使用一个简单的递归算法,尽管:
输出:
当然,这实际上是更一般的递归映射的一个特例,经过重构后,它看起来如下:
相关问题 更多 >
编程相关推荐