idcheck2.py 文件源码

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

项目:python 作者: hienha 项目源码 文件源码
def main():
    print 'Welcome to the Identifier Checker v2.0'
    myInput = raw_input('Identifier to test? ').strip()

    if len(myInput) == 0:
    print "ERROR: no identifier candidate entered"
    return

    if myInput in kwlist:
    print "ERROR: %r is a keyword" % myInput
    return

    alnums = ALPHAS + NUMS
    for i, c in enumerate(myInput):
    if i == 0 and c not in ALPHAS:
        print 'ERROR: first symbol must be alphabetic'
        break
    if c not in alnums:
        print 'ERROR: remaining symbols must be alphanumeric'
        break
    else:
    print "okay as an identifier"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号