在Python中,我们可以使用str()将int转换为String。
num1 = 100
print(type(num1)) # <class 'int'>
num2 = str(num1)
print(type(num2)) # <class 'str'>
输出量
<class 'int'>
<class 'str'>
参考文献
翻译自: https://mkyong.com/python/python-how-to-convert-int-to-string/
本文介绍Python中如何使用str()函数将整型(int)转换为字符串(str)类型。通过示例代码展示转换过程,并解释了转换后的类型变化。
1万+

被折叠的 条评论
为什么被折叠?



