【发布时间】:2018-03-12 14:18:59
【问题描述】:
这是来自“vpython.org”教程的简单代码:
from vpython import *
scene = canvas(title='Rubic solver!',
width=800, height=600,
center=vector(5,0,0), background=color.white,userzoom=0,userspin=0,userpan=0)
box()
while True:
ev = scene.waitfor('mousedown mouseup')
print(ev)
if ev.event == 'mousedown':
print('You pressed the mouse button')
else:
print('You released the mouse button')
print(ev.pos) # the position of the mouse
当我打印“ev”时,输出为 None,然后出现错误:
if ev.event == 'mousedown':
AttributeError: 'NoneType' object has no attribute 'event'
注意:我使用的是 Vpython7 和 Python3.6。
【问题讨论】:
-
为什么
scene.waitfor返回None? -
这是我的问题!
-
...除了你没有问任何问题。文档是怎么说的?
-
这段代码绝对来自文档,所以它说它不能返回 None。
标签: python python-3.x python-3.6 vpython