if __name__ == '__main__':
#创建车辆信息列表
list=["车次","出发站-到达站","出发时间","到达时间","历时","余票"]
trainNumber=['T40','T298','Z158','Z62']
address=['长春-北京','长春-北京','长春-北京','长春-北京']
getTime=['00:12','00:062','12:48','21:58']
outTime=['12:20','10:50','21:06','06:08']
lastTime=['12:08','10:44','08:18','8:20']
seate=['20','78','112','125']
print("{} {} {} {} {} {}".format(list[0],list[1],list[2],list[3],list[4],list[5]))#format():占位和定义占位顺序
print("{} {} {} {} {} {}".format(trainNumber[0],address[0],getTime[0],outTime[0],lastTime[0],seate[0]))
print("{} {} {} {} {} {}".format(trainNumber[1],address[1],getTime[1],outTime[1],lastTime[1],seate[1]))
print("{} {} {} {} {} {}".format(trainNumber[2],address[2],getTime[2],outTime[2],lastTime[2],seate[2]))
print("{} {} {} {} {} {}".format(trainNumber[3],address[3],getTime[3],outTime[3],lastTime[3],seate[3]))
#输入要购买的车次
train_number=input("请输入要购买的车次:")
#判断车次是否存在
if train_number in trainNumber:
print("车次存在")
else:
print("车次不存在,请重新输入")
#输入乘车人
username=input("请输入乘车人:")
#输出选择信息
print("您已购{}次列车{}开,请{}尽快换取纸质车票。【铁路客服】".format(train_number,address[trainNumber.index(train_number)],username))#index()索引一组有序的整数
#再次输出铁路信息
list=["车次","出发站-到达站","出发时间","到达时间","历时","余票"]
trainNumber=['T40','T298','Z158','Z62']
address=['长春-北京','长春-北京','长春-北京','长春-北京']
getTime=['00:12','00:062','12:48','21:58']
outTime=['12:20','10:50','21:06','06:08']
lastTime=['12:08','10:44','08:18','8:20']
seate=['18','78','112','125']
print("{} {} {} {} {} {}".format(list[0],list[1],list[2],list[3],list[4],list[5]))#format():占位和定义占位顺序
print("{} {} {} {} {} {}".format(trainNumber[0],address[0],getTime[0],outTime[0],lastTime[0],seate[0]))
print("{} {} {} {} {} {}".format(trainNumber[1],address[1],getTime[1],outTime[1],lastTime[1],seate[1]))
print("{} {} {} {} {} {}".format(trainNumber[2],address[2],getTime[2],outTime[2],lastTime[2],seate[2]))
print("{} {} {} {} {} {}".format(trainNumber[3],address[3],getTime[3],outTime[3],lastTime[3],seate[3]))