Python: “global name 'time' is not defined”
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm writing a silly program in python for a friend that prints "We are the knights who say 'Ni'!". then sleeps for 3 seconds, and then prints "Ni!" twenty times at random intervals using the random module's uniform() method. Here's my code: from time import sleep import random def knights_of_ni(): generator = random.Random() print "We are the knights who say 'ni'." sleep(3) for i in range(0,20): print "Ni!" sleep(generator.uniform(0,2)) I've tried to import this module by typing in the interpreter from silly import knights_of_ni() and import