TypeError: sequence item 0: expected str instance, int found的解决办法
2017-09-30 12:34
781 查看
TypeError: sequence item 0: expected str instance, int found
小例子:
a = ['1','2','3',1] print(' '.join(a))
以为会打印 1 2 3 1
结果报了错
Traceback (most recent call last): File "C:/Users/Administrator/Desktop/onetest.py", line 188, in <module> print(' '.join(a)) TypeError: sequence item 3: expected str instance, int found
上网查了资料,说list包含数字,不能直接转化成字符串。
解决办法:
print(" ".join('%s' %id for id in list1))
即遍历list的元素,把他转化成字符串。这样就能成功输出1 2 3 1了。
相关文章推荐
- python list转换字符串报错TypeError: sequence item 0: expected str instance, int found
- Android打包apk提示Error: Expected resource of type id [ResourceType]解决办法
- (Entlib 5.0)Activation error occured while trying to get instance of type ICacheManager, key ""求解决办法
- TypeError: 'str' object does not support item assignment 的解决方法
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- Error: Expected resource of type id [ResourceType]的解决办法
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- Androidstudio下打包apk提示Error: Expected resource of type id [ResourceType]解决办法
- python报错 TypeError: bad operand type for unary +: 'str' 的解决办法
- TypeError: Type str doesn't support the buffer API的解决办法
- TypeError: strptime() argument 0 must be str, not class 'bytes'解决办法
- Androidstudio下Generate signed apk提示Error: Expected resource of type id [ResourceType]解决办法
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- python中“TypeError: Can't convert 'int' object to str implicitly"报错的解决办法
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- Androidstudio下打包apk提示Error: Expected resource of type id [ResourceType]解决办法
- TypeError: document.body is null_js报错解决办法
- [virsh] error: unknown OS type hvm解决办法
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法