![](/img/trans.png)
[英]TypeError: unsupported operand type(s) for +: 'function' and 'int'
[英]TypeError: unsupported operand type(s) for *: 'function' and 'int'
def projet_catapulte(point_de_vie_1, point_de_vie_2) :
""" Jeu de catapulte joueur1 vs joueur2 tour à tour """
assert isinstance(point_de_vie_1, (int)), "Type a incorrect, il faut un int " # controle des types
assert isinstance(point_de_vie_2, (int)), "Type b incorrect, il faut un int" # des arguments
#var
point_d_impact=0.0 #float
temps=0.0 #float
i=0 #int
j=1 #int
angle=0.0 #float
#begin
point_de_vie_1=20
point_de_vie_2=20
while point_de_vie_1 > 0 or point_de_vie_2 > 0 :
#begin
i=1
while i > 0 :
#begin
print("joueur_1 joue")
angle=int(input("Entrez l'angle : "))
temps=(temps_appuie)
point_d_impact=((temps*angle)/38)
print(point_d_impact)
真的不知道這個typeError
temps_appuie
是一個函數,您已經在temps
引用了它。 也許您打算改稱它。
temps=(temps_appuie)
您正在temps
指向一個函數。 因此,在此聲明中
point_d_impact=((temps*angle)/38)
您正在將一個函數乘以一個angle
,該angle
是一個數字。 這就是為什么它失敗了。 您是不是要這樣調用函數?
temps=temps_appuie()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.