标签:pat 卸载 python time() 3.1 sleep div 结果 span
编写一个进度条
1 import sys,time 2 for i in range(1,100): 3 if i < 9:#判断是否是占两位数 4 sys.stdout.write(‘#‘+‘%‘+str(i+1)+"\b\b")#进度条退两格,为连接下一个#腾地方 5 sys.stdout.flush()#刷新显示 6 time.sleep(0.5) 7 else: 8 sys.stdout.write(‘#‘ + ‘%‘ + str(i + 1) + "\b\b\b") 9 sys.stdout.flush() 10 time.sleep(0.5)
1 time.sleep(5) 2 print("wake up ....") 3 print(time.time())#时间戳1970 1 1到现在的过去多少秒 4 print(time.ctime())#返回当前时间 5 print(time.ctime(time.time()-86400))#将时间转换成字符串昨天的这个时间 6 time_obj=time.gmtime(time.time()-86400) 7 print(time_obj) 8 print("%d-%f-%s %s:%s" % (time_obj.tm_year,time_obj.tm_mon,time_obj.tm_mday,time_obj.tm_hour,time_obj.tm_min)) #格式化 9 # import sys
"""
wake up ....
1507429553.1381178
Sun Oct 8 10:25:53 2017
Sat Oct 7 10:25:53 2017
time.struct_time(tm_year=2017, tm_mon=10, tm_mday=7, tm_hour=2, tm_min=25, tm_sec=53, tm_wday=5, tm_yday=280, tm_isdst=0)
2017-10.000000-7 2:25
"""
1 import datetime 2 print(datetime.datetime.now())#返回当前系统时间 3 print(datetime.date.fromtimestamp(time.time()))#时间戳直接转成日期格式 4 print(datetime.datetime.now() + datetime.timedelta(3))#当前时间加三天 5 print(datetime.datetime.now() + datetime.timedelta(-3))#当前时间减三天 6 print(datetime.datetime.now() + datetime.timedelta(hours=3))#当前时间加3小时 7 print(datetime.datetime.now() + datetime.timedelta(minutes=30))#当前时间加30分钟
"""
运行结果
2017-10-08 11:11:59.362852
2017-10-08
2017-10-11 11:11:59.362852
2017-10-05 11:11:59.362852
2017-10-08 14:11:59.362852
2017-10-08 11:41:59.362852
"""
sys模块
sys.path()其中有一个目录Python35\\lib\\site-packages将写好的py放入其中,import 就可以导入,一般import导入则在当前目录,如果想在任何地方都可以导入就放入site-packages中
sys.argv运行后面带的参数
1 import sys 2 print(sys.path) 3 print(sys.argv) 4 if sys.argv[1] == ‘sleep‘: 5 print("hello") 6 else: 7 print("wakeup")
"""
H:\python17\w4>python timemodle.py sleep
[‘timemodle.py‘, ‘sleep‘]
hello
H:\python17\w4>python timemodle.py sleep
[‘H:\\python17\\w4‘, ‘C:\\Python27\\lib\\site-packa
ges\\paramiko-1.13.0-py2.7.egg‘, ‘C:\\Windows\\syst
em32\\python27.zip‘, ‘C:\\Python27\\DLLs‘, ‘C:\\Pyt
hon27\\lib‘, ‘C:\\Python27\\lib\\plat-win‘, ‘C:\\Py
thon27\\lib\\lib-tk‘, ‘C:\\Python27‘, ‘C:\\Python27
\\lib\\site-packages‘]
[‘timemodle.py‘, ‘sleep‘]
如果想安装django
在Scripts目录中找到pip.exe
在命令行中运行pip.ext install django
卸载pip.exe uninstall django
标签:pat 卸载 python time() 3.1 sleep div 结果 span
原文地址:http://www.cnblogs.com/wang43125471/p/7636752.html