數字轉為字符串類型報錯:TypeError: 'str' object is not callable


Python中數字轉化為字符串

  • 報錯的寫法
### 這樣直接轉換會報錯
num_te = 88888
print(str(num_te))

# 錯誤信息
# TypeError: 'str' object is not callable

  • 修改后的寫法
num_te = 88888
print('%d'%num_te, type('%d'%num_te))
# 結果 =====>成功轉化為了str類型
# 88888 <class 'str'>

詳細內容請參考: https://blog.csdn.net/bigsea622/article/details/82703190


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM