common.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:twitterApiForHumans 作者: vaulstein 项目源码 文件源码
def ask_timezone(question, default, tzurl):
    """Prompt for time zone and validate input"""
    lower_tz = [tz.lower() for tz in pytz.all_timezones]
    while True:
        r = ask(question, str_compat, default)
        r = r.strip().replace(' ', '_').lower()
        if r in lower_tz:
            r = pytz.all_timezones[lower_tz.index(r)]
            break
        else:
            print('Please enter a valid time zone:\n'
                  ' (check [{0}])'.format(tzurl))
    return r
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号