[已解决]报错: TypeError: sequence item 0: expected str instance, int found
2020-06-08 07:15
731 查看
钉钉、微博极速扩容黑科技,点击观看阿里云弹性计算年度发布会!>>>
今天敲小例子,报了错TypeError: sequence item 0: expected str instance, int found
小例子
list1=[1,'two','three',4] print(' '.join(list1))
以为会打印1 two three 4
结果报了错
Traceback (most recent call last): File "<pyshell#27>", line 1, in <module> print(" ".join(list1)) TypeError: sequence item 0: expected str instance, int found
上网查了资料,说list包含数字,不能直接转化成字符串。
解决办法:
print(" ".join('%s' %id for id in list1))
即遍历list的元素,把他转化成字符串。这样就能成功输出1 two three 4结果了。
相关文章推荐
- TypeError: sequence item 0: expected str instance, int found的解决办法
- python list转换字符串报错TypeError: sequence item 0: expected str instance, int found
- TypeError: sequence item 0: expected str instance, int found
- TypeError: sequence item 0: expected str instance, int found
- python list转换字符串报错TypeError: sequence item 0: expected str instance, int found
- python list转换字符串报错TypeError: sequence item 0: expected str instance, int found
- TypeError: sequence item 0: expected str instance, dict found 类型错误
- TypeError: 'str' object does not support item assignment 的解决方法
- Androidstudio下打包apk提示Error: Expected resource of type id [ResourceType]解决办法
- python中“TypeError: Can't convert 'int' object to str implicitly"报错的解决办法
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- TypeError: strptime() argument 0 must be str, not class 'bytes'解决办法
- Error: Expected resource of type id [ResourceType]的解决办法
- Android错误-error:Foundtext""whereitemtagisexpected的解决方法
- 解决:error: Cannot fetch repo (TypeError: expected string or buffer)
- python 点滴记录4:TypeError: range() integer end argument expected, got str.
- python 报错TypeError: 'range' object does not support item assignment,解决方法
- python3环境下 tensorflow环境中经常遇到'*' has type str, but expected one of: bytes问题的解决
- 解决错误: TypeError: 'str' object is not callable
- TypeError: 'builtin_function_or_method' object has no attribute '__getitem__'(已解决)