Python cmd模块命令别名 [英] Python cmd module command aliases

查看:168
本文介绍了Python cmd模块命令别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用cmd模块在Python 3.1.1中创建了一个命令行界面。

I am making a command line interface in Python 3.1.1 using the cmd module.

有一种方法来创建一个命令, 退出和退出?
或者它只是一个例子,使一些命令都引用相同的函数?

Is there a way to create a command with more than one name e.g. "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.

这篇关于Python cmd模块命令别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆