python 的isdigit()

def is_isbn_or_key(word):

    isbn_or_key='key'
    '''
    isdigit()方法检测字符串是否只由数字组成。
    '''
    if len(word)==13 and word.isdigit():
        isbn_or_key='isbn'

    short_word=word.replace('-','')
    if len(short_word)==10 and short_word.isdigit():
        isbn_or_key='isbn'

    return isbn_or_key
原文地址:https://www.cnblogs.com/tangqiu/p/12565853.html