简体   繁体   English

Python cmd模块命令别名

[英]Python cmd module command aliases

I am making a command line interface in Python 3.1.1 using the cmd module. 我正在使用cmd模块在Python 3.1.1中创建命令行界面。

Is there a way to create a command with more than one name eg "quit" and "exit"? 有没有一种方法可以创建一个具有多个名称的命令,例如“退出”和“退出”? Or would it just be a case of making a number of commands that all reference the same function? 还是只是制作许多都引用相同功能的命令?

Yes, it would just be a case of making a number of commands that all reference the same function. 是的,这只是做许多都引用相同功能的命令的情况。

This is common. 这很常见。 It often helps to provide multiple common aliases for a command. 它通常有助于为命令提供多个通用别名。 It makes the user's life simpler because the odds of them guessing correctly are improved. 由于提高了用户正确猜测的几率,因此使用户的生活变得更加简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM