PYTHON教程之import模块

2018年4月6日12:39:20 发表评论 176 views

PYTHON教程之import模块

PYTHON教程之import模块

#1.引用其他文件的方法import time 指 import time 模块,这个模块可以python自带,
# 也可以是自己安装的,比如以后会用到numpy这些模块,需要自己安装。
import time
print(time.localtime())  #这样就可以print 当地时间了
#2.import time as __,__下划线缩写部分可以自己定义,在代码中把time 定义成 t.
import time as t
print(t.localtime()) # 需要加t.前缀来引出功能
#3.from time import time,localtime ,只import自己想要的功能.
from time import time, localtime
print(localtime())
print(time())
#4.from time import * 输入模块的所有功能
from time import *
print(localtime())

运行结果:

"D:\Program Files\python\python.exe" "D:/Program Files/python/example/PYTHON教程之import模块.py"
time.struct_time(tm_year=2018, tm_mon=4, tm_mday=6, tm_hour=12, tm_min=33, tm_sec=59, tm_wday=4, tm_yday=96, tm_isdst=0)
time.struct_time(tm_year=2018, tm_mon=4, tm_mday=6, tm_hour=12, tm_min=33, tm_sec=59, tm_wday=4, tm_yday=96, tm_isdst=0)
time.struct_time(tm_year=2018, tm_mon=4, tm_mday=6, tm_hour=12, tm_min=33, tm_sec=59, tm_wday=4, tm_yday=96, tm_isdst=0)
1522989239.5231764
time.struct_time(tm_year=2018, tm_mon=4, tm_mday=6, tm_hour=12, tm_min=33, tm_sec=59, tm_wday=4, tm_yday=96, tm_isdst=0)

Process finished with exit code 0

 

 

51changxue

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: