python-3.x - randint 不想与 int 相乘,然后从 int 中减去
问题描述
您好,我是 python 3.x 的初学者,出于某种原因,我的 randint 不想像以前那样工作。我有一个分数,应该减去 1 到 5 之间的随机数乘以你的攻击值。这以前可以正常工作,但现在当我尝试这样做时:
while php > 0:
doing = input(print('What will', starter, 'do? '))
if doing == 'attack':
php -= randint(1,5) * atk
hp -= randint(1,5) * patk
这曾经工作得很好,但现在它说:
line 61, in <module>
hp -= randint(1,5) * patk
TypeError: unsupported operand type(s) for -=: 'function' and 'int'
我不知道该怎么办。可能是因为函数与 int(hp) 共享名称吗?
解决方案
推荐阅读
- python - Python:curve_fit 不适用于具有三个拟合参数和不正确积分的函数
- javascript - Croppie 结果发送到 Web 服务器
- jquery - 单击时将 Font Awesome 图标重置为原始图标
- postgresql - 在 Postgresql 中为定义的时间段添加重复操作
- c# - .NetStandard 2.0,MongoDB 驱动程序:MongoDB.Bson 的 FileNotFoundException
- mysql - 简单优化查询 - MYSQL
- c - 为什么 gcc 即使在使用 f 后缀后仍将浮点文字转换为 double 但 clang 似乎没有?
- html - 为什么居中和超链接的图像左右两侧的空白是可点击的?
- linux - 在 Linux 脚本中接收“curl: (3) Illegal characters found in URL”
- javascript - Javascript - 为什么 Ramda over 函数在这里不起作用?