繁体   English   中英

TypeError:*:'function'和'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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM