NameError:未定义名称“显示”

时间:2019-05-31 21:41:34

标签: vpython

不确定为什么现在会出现此错误,因为它在我上次运行代码时对我有用...

我重试了一个新文件,然后继续获取错误。我基本上是从教程中复制此代码的,并主动尝试自己更好地理解vpython,但无法通过该奇怪的错误。很奇怪,因为我上次运行良好,而且我什么也没改变。甚至关闭了Spyder并重新打开它。

# PROJECTILE MOTION!!!!!!!!
from vpython import *

#This imports all names except those beginning with an underscore (_)

display(width = 1300, height = 1000)

projectile = sphere(pos = vector(-5,0,0),
                    radius = 0.5,
                    color = color.red,
                    make_trail = True)

projectile.speed = 3 # initial speed
projectile.angle = pi*30/180 # 30 degree angle. Initial angle
projectile.velocity = vector(projectile.speed*cos(projectile.angle),
                             projectile.speed*sin(projectile.angle),
                             0)

projectile.mass = 1.0
grav_field = 9.81
dt = 0.01
time = 0

while (projectile.pos.y >= 0):
    rate(100) # Rate statement needed to display motion between initial and 
    #final positions.

    # Caclulate force:
    grav_force = vector(0, -projectile.mass*grav_field, 0) # F=MA
    force = grav_force
    # update velocity (momentum):
    projectile.velocity = projectile.velocity + force/projectile.mass * dt
    # Vf = Vi - gdt

    # Update position:
    projectile.pos = projectile.pos + projectile.velocity * dt
    # Xf = Xi + Vdt

    # Update time:
    time += dt

(基本)C:\ Users \ parkd> Projectilemotion.py 追溯(最近一次通话):   文件“ C:\ Users \ parkd \ MyScripts \ Projectilemotion.py”,第6行,在     显示(宽度= 1300,高度= 1000)

NameError:名称“ Display”未定义

0 个答案:

没有答案