Python中拼接字符串和数字时报错如何处理
展开全部
Python拼接字符串和数字时会报错, 代码如下
import osimport sys
str = 'Python学科的分数为:'score = 90print str + str(score) + '分'
执行结果:
Traceback (most recent call last):
File "C:/Users/Administrator/PycharmProjects/Python_Demo/filedemo.py", line 9, in <module>
print str + str(score) + '分'
TypeError: 'str' object is not callable
import osimport sys
str = 'Python学科的分数为:'score = 90print str + str(score) + '分'
执行结果:
Traceback (most recent call last):
File "C:/Users/Administrator/PycharmProjects/Python_Demo/filedemo.py", line 9, in <module>
print str + str(score) + '分'
TypeError: 'str' object is not callable
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询