我想生成一个随机数,以后再使用。它也起作用,模拟加载大约0.5秒,然后我看到了。但是随后模拟崩溃,模拟窗口退出。我也不能使用例如import random
发生相同的事情。可能是随机软件包不适用于Vpython吗?
Syntax error File "/Users/colinm/Desktop/random.py", line 2 import random from randint ^ SyntaxError: invalid syntax –
代码
from vpython import*
import random from randint
#Sonne
sun = sphere(pos = vec(0,0,0), radius = 9, make_trail = True )
sun.mass = 2e30
sun.velocity = vec(0,0,0)
#Merkur
mercury_pos_x = randint(1, 100)
mercury = sphere(pos = vec(mercury_pos_x,0,0), radius = 5, color=color.red, make_trail = True )
mercury.mass = 3.25e23
mercury.velocity = vec(0,0,-47000)
#Venus
venus_pos_x = randint(1, 100)
venus = sphere(pos = vec(venus_pos_x,0,0), radius = 6, color=color.cyan, make_trail = True )
venus.mass = 4.9e24
venus.velocity = vec(0,0,-35000)