?? plural1.py
字號:
"""Pluralize English nouns (stage 1)This program is part of "Dive Into Python", a free Python book forexperienced programmers. Visit http://diveintopython.org/ for thelatest version.Command line usage:$ python plural1.py nounnouns"""__author__ = "Mark Pilgrim (mark@diveintopython.org)"__version__ = "$Revision: 1.3 $"__date__ = "$Date: 2004/03/18 16:43:37 $"__copyright__ = "Copyright (c) 2004 Mark Pilgrim"__license__ = "Python"import redef plural(noun): if re.search('[sxz]$', noun): return re.sub('$', 'es', noun) elif re.search('[^aeioudgkprt]h$', noun): return re.sub('$', 'es', noun) elif re.search('[^aeiou]y$', noun): return re.sub('y$', 'ies', noun) else: return noun + 's'if __name__ == '__main__': import sys if sys.argv[1:]: print plural(sys.argv[1]) else: print __doc__
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -