python将转字符串类型
时间: 2023-10-04 22:04:49 浏览: 115
字符串类型转换
使用`str()`函数将其他类型转换为字符串类型,例如:
```
num = 123
str_num = str(num)
print(str_num) # 输出:"123"
```
如果要将多个元素转换为字符串并拼接起来,可以使用`join()`方法,例如:
```
list_num = [1, 2, 3]
str_num = ''.join(str(i) for i in list_num)
print(str_num) # 输出:"123"
```
阅读全文