我正在创建一个程序,将模拟一个Nba球员的球场线。我是一名初学者,不幸的是我遇到了以下错误:
TypeError: '>' not supported between instances of 'tuple' and 'int'
此错误发生在处,而数字>;0:
以下是我目前的代码:
import random
Malcolm_Brogdon_tendencies = { "Under_Basket_Rate" : 396,
"Close_Left_Rate" : 32, "Close_Mid_Rate" : 50, "Close_Right_Rate" : 38, "Mid_Left_Rate" : 6, "Mid_Mleft_Rate" : 36, "Mid_Mleft" : 375, "Mid_Mid_Rate" : 47,
"Mid_Mright_Rate" : 83, "Mid_Right_Rate" : 15, "Three_Left_Rate" : 8, "Three_Mleft_Rate" : 91, "Three_Mid_Rate" : 70, "Three_Mright_Rate" : 109, "Three_right_Rate" : 18}
Malcolm_Brogdon_Percentages = {"Under_Basket" : 487, "Close_Left" : 571, "Close_Mid" : 515, "Close_Right" : 480, "Mid_Left" : 500, "Mid_Mleft" : 375,
"Mid_Mid" : 452, "Mid_Mright" : 564, "Mid_Right" : 400, "Three_Left" : 0, "Three_Mleft" : 350, "Three_Mid" : 261, "Three_Mright" : 319, "Three_Right" : 417}
Malcolm_Brogdon_Person = {"Shot_Attempts" : random.randint(10,16)}
do_not_include = [0]
total_shots = 0
while total_shots< Malcolm_Brogdon_Person["Shot_Attempts"]:
for tendencies, numbers in Malcolm_Brogdon_tendencies.items():
for numbers in Malcolm_Brogdon_tendencies.items():
while numbers > 0:
shot_distribution = random.randint(1,1001)
if shot_distribution not in do_not_include:
do_not_include.append(shot_distribution)
total_shots = total_shots + 1
numbers = numbers - 1
print (do_not_include)
我也明白,从互联网导入数据会更容易,但是,我希望开始的速度较慢。这些数字表示每个1000次中会发生多少次。然后,对于Malcolm_Brogdon_Tendencies
中的每一个,它将生成1000个数字中的许多数字,并为它们分配一个值,例如Close_Left_Rate
将发生32/1000次。也许有一种更简单的方法可以做到这一点,但是,我对编程还不熟悉,也不知道那么多
我知道变量numbers是Malcolm_Brogdon_Tendencies
中的值,不能与int进行比较。有没有办法在解析数字之前将其作为int
感谢所有帮助我的人,因为我意识到我给出了一个可怕的描述,我的代码可能会简化很多
试着替换
与
这就是它只比较元组中的整数的方法
可能您正试图访问项中(键、值)对的数字部分,因此请尝试替换
与
相关问题 更多 >
编程相关推荐