`Traceback (most recent call last):
File "fmcrawler_sql.py", line 317, in <module>
crawl(initFighter=fighter,K=4)
File "fmcrawler_sql.py", line 114, in crawl
write_page_to_database(initFighterURL,cur)
File "fmcrawler_sql.py", line 292, in write_page_to_database
write_fights_to_database(fights,cur)
File "fmcrawler_sql.py", line 211, in write_fights_to_database
fightId = hash(bothFighters+fight['Event'])
TypeError: cannot concatenate 'str' and 'list' objects
`
这些线路怎么了?你知道吗
从你发布的内容看不出发生了什么,但是这个错误很常见。在实际代码的某个地方,您正试图连接(或添加)一个字符串和一个列表。问题出现在这里:
我猜
bothFighters
是一个列表,fight['Event']
是一个字符串。将字符串更改为列表,错误可能会消失。(Python允许您一起“添加”列表,用两个列表的第一级条目创建一个较长的列表)。你知道吗如果仍然需要帮助,请使用代码进行更新。你知道吗
List concatenation in Python
String concatenation basics if you ever need 'em.
阅读
TypeError
:你有一个字符串和一个列表…什么是列表是显而易见的,所以你需要把'Event'从列表中取出,并与另一个变量连接起来-然后放回一个列表中。取决于你需要什么。你知道吗相关问题 更多 >
编程相关推荐