先看代码:
import time #利用import print "how", time.sleep(2) #sleep()方法前面必须得有导入模块的名字time print "are", time.sleep(2) print "you", time.sleep(2) print "today?" from time import sleep #利用from...import... print "how", sleep(2) #sleep()方法前面就不要有导入模块的名字了 print "are", sleep(2) print "you", sleep(2) print "today?" 结果 how are you today? how are you today?
区别我在代码中的注释部分已经写出了。