数字转为字符串类型报错: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

posted @ 2020-07-16 15:49  新人王小五  阅读(1455)  评论(0)    收藏  举报