【发布时间】:2021-04-17 22:06:18
【问题描述】:
我想在我的 python 脚本中创建终端命令。
例如,
$ cd my_project_folder $ --help(我在这个python文件夹中使用了一个命令)
输出 $ this is the help command. You've activated it using --help. This is only possible because you cd'd to the folder and inputted this command.
我正在寻找用户定义的命令(我已经在我的 python 函数中定义的命令。)
我不是在寻找像“ls”和“pwd”这样的命令。
【问题讨论】:
-
没有。我想做我自己的命令。假设我已经打印了“我的名字是乔”。现在,如果用户输入“--hello”,这是我创建的命令,脚本将打印“hi!”
-
@Nqx 所以我的理解是,您正在寻找通过
$ some_defined_command调用脚本?比如$ hello,它调用了一个python函数? -
@Leemosh 正确!
标签: python python-3.x shell terminal command