鱼C论坛

 找回密码
 立即注册
查看: 11111|回复: 5

Python代码报错:TypeError: randint() missing 1 required positional argument: 'b'

[复制链接]
发表于 2019-3-1 11:13:43 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x

Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "C:/temp/helloworld/雪花.py", line 18, in <module>
    speedx = random.randint(-1.2)
TypeError: randint() missing 1 required positional argument: 'b'



for i in range(300):
    x = random.randrange(0,SIZE[0])
    y = random.randrange(0,SIZE[1])
    speedx = random.randint(-1.2)
    speedy = random,randint(3,8)
    snow.append([x,y,speedx,speedy])
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2019-3-1 11:14:25 | 显示全部楼层
random.randint(-1,2)
里面是逗号
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-3-1 11:15:18 | 显示全部楼层
我刚刚改成逗号了,但是又报这个错:
Traceback (most recent call last):
  File "C:/temp/helloworld/雪花.py", line 19, in <module>
    speedy = random,randint(3,8)
NameError: name 'randint' is not defined
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-3-1 11:17:55 | 显示全部楼层
陈芳芳 发表于 2019-3-1 11:15
我刚刚改成逗号了,但是又报这个错:
Traceback (most recent call last):
  File "C:/temp/helloworld/ ...

你该用点的地方又用了逗号,自己看吧
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-3-1 11:50:05 | 显示全部楼层
speedy = random,randint(3,8)  

把逗号改成点
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-3-1 14:01:54 | 显示全部楼层
TypeError: 'int' object is not subscriptable

再请教一下,这个报错又是什么?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-1-14 06:27

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表