Re: python 写命令行程序
"Jiahua Huang" <[email protected]>
| Newsgroups | gmane.comp.python.chinese |
|---|---|
| Message-ID | <[email protected]> |
你是说设计参数?
不如首先看 python 怎么处理参数的
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
[ 多个短参数/--长参数] [文件/命令] [其他选项]
两杠开头的为长参数,类似
--encode utf8 或 --encode=utf8
单杠开头的为短参数,或长参数缩写,类似
-d utf8 或 -d=utf8
第一个非 - 开头的为文件/命令
文件/命令后的 是其他参数
贴个实例:
$ zshelve
commandline tool for zshelve databases
Usage: zshelve FILE dump Dump the data tree
zshelve FILE keys List of keys
zshelve FILE get KEY Dump value for key
zshelve FILE set KEY VALUE Set db[key] = value
zshelve FILE has_key KEY True if database has the key
zshelve FILE search_key KEY Search key
zshelve FILE search_value VALUE Search value
2008/1/16 tairan wang <[email protected]>:
>
> 打算用一个python写一个命令行的程序,不知道处理的参数的逻辑如何设计。请给些提示!:)
>
> Thanks
>
_______________________________________________
python-chinese
Post: send [email protected]
Subscribe: send subscribe to [email protected]
Unsubscribe: send unsubscribe to [email protected]
Detail Info: http://python.cn/mailman/listinfo/python-chinese