Python 对英语单词单数变复数

来源:互联网 发布:淘宝网 刀具 违法 编辑:程序博客网 时间:2024/05/17 07:48
def plural(word):    if word.endswith('y'):        return word[:-1] + 'ies'    elif word[-1] in 'sx' or word[-2:] in ['sh', 'ch']:        return word + 'es'    elif word.endswith('an'):        return word[:-2] + 'en'    else:        return word + 's'

0 0