要将一个Python数字转换为字符串,可以使用内置的str()函数。示例如下:
str()
num = 123 str_num = str(num) print(str_num) # 输出:'123'
另外,也可以使用字符串的format()方法来将数字插入到字符串中,例如:
format()
num = 123 str_num = "The number is {}".format(num) print(str_num) # 输出:'The number is 123'