[英]how do you change an integer to a string in python?
我正在尝试编写游戏代码,但它不断弹出can only concatenate str (not "int") to str
我试过print('sample text' + variable + 'sample text')
您可以转换为str
或使用 f 字符串(格式字符串)。
print('sample text' + str(variable) + 'sample text')
或者
print(f'sample text {variable} sample text')
尝试使用print(str(variable))
用字符串包装它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.