day16:包

#
import time
print(time.time())#从1970年1月1日到现在的秒数

import time as xiaogou
print(xiaogou.time())

import time
while True:
   
print(time.time())
    time.sleep(
1)

 

 

 

#新建xiaogou.py文件

import xiaogou as a

a.Dog()

a.ErHa()

 

 

 

# from xiaogou import Dog,ErHa

from xiaogou import Dog as a,ErHa as b

a()

b()

 

 

 

from xiaogou import *

from xiaogou import Benz,eat

a=Benz("京A88888")

a.run()

eat()

 

 

 

from xiaogou import *

a=Benz("京A9898")

print("你好修车的")

 

 

 

if __name__=="__main__":#如果直接运行此模块,那么就输出if里的内容

    print("你好奔驰")

else:

    print("名字",__name__)#如果在其他模块调用此模块的内容,就输出else里的内容

 

 

 

from xiaogou import *

A()

B()



 

 

 

from xiaogou import A,B

A()

B()#不会报错,因为all只限制*导入,不限制直接用模块导入

 

 

 

from xiaogou import *

A()

B()#会报错,因为xiaogou的all里没有B

 

 

 

 

#创包buy,sell
 
 
 
 
 
 
deal.py:
 
import buy.buy_fruit

buy.buy_fruit.buy_apple()

from buy import buy_vegetable

buy_vegetable.buy_tomato()
 
 
 
 
deal.py
 
import sys

sys.path.append("D:\\workpy\\buy")

print(sys.path)
 
 
 
 
 
 
#在buy\\__init__中添加__all__
 
 
deal.py:

from buy import *#如果不在__init__中添加__all__,则无法调用buy_fruit和buy_vegetable

buy_fruit.buy_apple()

buy_vegetable.buy_tomato()

hello()#当__init__中没有__all__时可以调用__init__中的hello()函数,若__all__存在且__all__中没有hello时,此处无法调用hello()
 
 
 
 
 
 
import time

t1=time.mktime(time.strptime("2019-03-04 14:06:05","%Y-%m-%d %H:%M:%S"))

while True:

    now=time.time()

    # tim1=now-t1

    # day1=tim1//(60*60*24)

    # hour1=tim1%(60*60*24)//(60*60)

    # min1=tim1%(60*60*24)%(60*60)//60

    # sec1=tim1%(60*60*24)%(60*60)%60

    # print("已过%d天%d小时%d分钟%d秒"%(day1,hour1,min1,sec1))

    t2=t1+7*24*60*60

    tim2=t2-now

    day2=tim2//(60*60*24)

    hour2=tim2%(60*60*24)//(60*60)

    min2=tim2%(60*60*24)%(60*60)//60

    sec2=tim2%(60*60*24)%(60*60)%60

    print("还剩%d天%d小时%d分钟%d秒"%(day2,hour2,min2,sec2))

    time.sleep(1)
 
 
 
 
 
 
#发布包
创建一个新的文件夹
 
 
 
 
 
 
(刚创建时没有build、dist两个文件夹和MANIFEST文件,这些文件夹和文件是后面过程添加进去的)
 
 
 
 
 
 
 
 
将baoljj中dist文件夹中的压缩包解压
 
 
 
 
 
import test11

test11.heihei()
 

猜你喜欢

转载自blog.csdn.net/weixin_43800846/article/details/88542365