Python名词单数变换为复数函数

时间:2014-04-10 15:55:34   收藏:0   阅读:966
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.endwith(‘an‘):
        return word[-2:]+‘en‘
    else:
        return word+‘s‘

Python名词单数变换为复数函数,布布扣,bubuko.com

原文:http://blog.csdn.net/guoqingchun/article/details/23350925

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!