簡體   English   中英

python 中的 INT 到 STRING 轉換

[英]INT to STRING conversion in python

我無法使用str()將 int 轉換為string 在互聯網上的任何地方,我都發現str()用於將int轉換為string

我試圖在jupyter notebook上運行它

我的代碼:

num=23
string=str(num)

錯誤:

TypeError  Traceback (most recent call last)
ipython-input-24-63bcf2e7ab44> in <module>
       1 num=23
 ----> 2 string=str(num)
TypeError: 'str' object is not callable

在早些時候的某個地方,你做了:

str = 'somestr goes here'

永遠不要命名變量str 它導致了這個問題。 您現在可以使用以下方法更正它:

del str

但未來的解決方案是永遠不要使用str作為變量名。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM