[英]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.