-z        直达
Examples:
tickets 上海安阳 2016-10-10
激励语言
tickets -dg 上海安阳 2016-10-10
"""交通事故赔偿
import requests
from docopt import docopt
from prettytable import PrettyTable
from colorama import init, Fore
from stations import stations
新买的电脑怎么分区init() # init(autoreset=True) 添加了这个参数之后,对于输出的颜⾊就不需要每次都Fore.RESET
张文慈三级
class TrainsCollection:
header = '车次车站时间历时⼀等⼆等软卧硬卧硬座⽆座'.split()
def __init__(self, available_trains, options):
"""查询到的⽕车班次集合
:param available_trains: ⼀个列表, 包含可获得的⽕车班次, 每个
⽕车班次是⼀个字典
:param options: 查询的选项, 如⾼铁, 动车,
"""
self.available_trains = available_trains
self.options = options
def _get_duration(self, raw_train):
duration = ('lishi').replace(':', '⼩时') + '分'
if duration.startswith('00'): # 如果字符串是以00开头的则返回TRUE
return duration[4:]
if duration.startswith('0'):
return duration[1:]
return duration
@property
def trains(self):
for raw_train in self.available_trains:
raw_train = ('queryLeftNewDTO')
if raw_train is not None and raw_train != '':
train_no = raw_train['station_train_code']
initial = train_no[0].lower()
if not self.options or initial in self.options:
train = [
train_no,
'\n'.join([Fore.GREEN + raw_train['from_station_name'] + Fore.RESET,
Fore.RED + raw_train['to_station_name'] + Fore.RESET]),
'\n'.join([Fore.GREEN + raw_train['start_time'] + Fore.RESET,
Fore.RED + raw_train['arrive_time'] + Fore.RESET]),
self._get_duration(raw_train),
raw_train['zy_num'],防控疫情正能量句子
类似失落大陆的小说raw_train['ze_num'],
raw_train['rw_num'],
raw_train['yw_num'],
raw_train['yz_num'],
raw_train['wz_num'],
]
yield train
def pretty_print(self):
pt = PrettyTable()
pt._set_field_names(self.header)
for train ains:
pt.add_row(train)
print(pt)
def cli():
"""Command-line interface"""
arguments = docopt(__doc__)
from_station = (arguments['<from>'])
to_station = (arguments['<to>'])
date = arguments['<date>']
url = ('kyfw.12306/otn/leftTicket/ain_date={}&leftTicketDTO.from_station={}&_station={}&purpose_codes=ADULT').format(                date, from_station, to_station