>>> s = "1 16 32" # string
>>> s.split() # this returns a list of strings
['1', '16', '32']
>>> s.split()[0] + 1 # you can't add an int to a string
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Can't convert 'int' object to str implicitly
我怀疑您所描述的错误消息对于这段代码可能不准确,但问题是您试图将字符串列表视为int列表。例如
如果要将它们视为int(或float),则需要将转换添加为
^{pr2}$相关问题 更多 >
编程相关推荐