实现停车记录

import sys
import datetime
now = datetime.datetime.now()

if sys.argv[1]=='checkin' and sys.argv[2] =='-t=st'and sys.argv[3].split("=")[0] == '-n':
in_data = sys.argv[3].split('=')[1]+' '+str(now.strftime('%Y-%m-%d %H:%M:%S'))+' '+'in'
print(in_data)
with open('data.txt','a+') as of:
of.write(in_data +'\n')
elif sys.argv[1]=='checkout' and sys.argv[2]=='-t=et' and sys.argv[3].split("=")[0]=='-n':
out_data = sys.argv[3].split("=")[1]+' '+str(now.strftime('%Y-%m-%d %H:%M:%S'))+' '+'out'
print(out_data)
with open('data.txt','a+') as of:
of.write(out_data +'\n')

elif sys.argv[1]=='listrecord' and sys.argv[2]=='-all':
with open('data.txt','r') as of:
print(of.read())

转载于:https://www.cnblogs.com/ITniu/p/6486233.html

你可能感兴趣的:(实现停车记录)