2012-08-28 51 views
2

我試過四處尋找答案,但是這裏的問題要麼先進一步(我是Python的新手),要麼是因爲重新定義了我在腳本中無法捕獲的東西。這裏是代碼 -str對象不可調用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)) 

我收到錯誤類型錯誤:「海峽」對象不是可調用

這是一個簡單的腳本,我知道,但它是一項正在進行的工作。

+0

你使用Python 2或3? –

回答

11

假設你使用Python 3,

print ("The area of your shape is: ", (a*b)) 
#         ^

你忘了一個逗號。

+0

這樣做會感謝你。 – user1630407

+0

@ user1630407:點擊左側的複選標記,您可以接受此答案爲正確答案。 –

1

可以打印值要麼:

print ("The area of your shape is: ", (a*b)) 

print ("The area of your shape is: {}".format(a*b)) 
+1

,或者如果你希望它能夠像python 2.6那樣工作,那麼''{0}「'。 – mgilson