这次我们来做一个实战任务——停车场管理系统制作。

停车场管理系统,需要记录进入车辆,和计算价格,删除驶出车辆,还有地库车录入等等。

答案:

import datetime
a={}
yzc=[]#地库车列表
b=30#剩余车位
def tr(b):
    d=input("车牌号")
    bn=0
    for x in yzc:
        if x==d:
            print("欢迎光临,",d)

            bn=1
    if bn==1:
        pass
    else:
        if b<=0:
            print("对不起,车位已满")
        else:

            c=datetime.datetime.now().hour
            print("欢迎光临,",d)
            
            b-=1
            print("余位",b,"个")
    return b,d,c
print("余位",b,"个")
while 1==1:
    c=input("1.进场,2出场")
    if c=="1":
        b,d,c=tr(b)
        a[d]=c
    elif c=="2":
        e=input("车牌号")
        f=0
        g=0
        qwertyu=1
        try:

            www=datetime.datetime.now().hour
            print(e,"费用",(www-a[e])*5,"元")
            qwertyu=0
            print(a[e],"一路顺风")

            
            b+=1
            print("余位",b,"个")
            
            a.pop(e)
            
        except Exception as asdfghjk:
            print("未找到此车辆")

    else:
        print("没有此选项")
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.

好了,今天的每日一练实战任务就到这里,下一次再见。