[英]str object is not callable python
我曾尝试四处寻找答案,但是这里的问题要么看起来很先进(我是 Python 新手),要么是因为重新定义了我无法在脚本中捕捉到的含义。 这是代码-
a = float(input("Enter the length(in inches)"))
b = float(input("Enter the width(in inches)"))
print ()
print ("The area of your shape is: "(a*b))
我收到错误TypeError: 'str' object is not callable 。
我知道,这是一个简单的脚本,但它仍在进行中。
假设您使用的是 Python 3,
print ("The area of your shape is: ", (a*b))
# ^
你忘记了逗号。
您可以使用以下方法打印值:
print ("The area of your shape is: ", (a*b))
或与
print ("The area of your shape is: {}".format(a*b))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.