Python 运行命令时 $ 是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19986306/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 15:09:55  来源:igfitidea点击:

What does the $ mean when running commands?

pythoncommandinstalldollar-sign

提问by joshpachan

I've been learning Python, and I keep running into the $ character in online documentation. Usually it goes something like this:

我一直在学习 Python,而且我一直在在线文档中遇到 $ 字符。通常它是这样的:

$ python ez_setup.py(Yeah, I've been trying to install setup tools)

$ python ez_setup.py(是的,我一直在尝试安装设置工具)

I'm fairly certain that this command isn't for the python IDE or console, but I've tried windows cmd and it doesn't work. Any help?

我相当肯定这个命令不适用于 python IDE 或控制台,但我已经尝试过 windows cmd 并且它不起作用。有什么帮助吗?

采纳答案by inspectorG4dget

As of now, Python does not implement $in its syntax. So, it has nothing to do with Python.

到目前为止,Python 还没有实现$它的语法。所以,它与 Python 无关。

Instead, what you are seeing is the terminal prompt of a Unix-based system (Mac, Linux, etc.)

相反,您看到的是基于 Unix 的系统(Mac、Linux 等)的终端提示。

回答by inspectorG4dget

The $is the command prompt. It is used to signify that python ez_setup.pyshould be run on a command line and not on a python/perl/ruby shell

$是命令提示。它用于表示python ez_setup.py应该在命令行上运行而不是在 python/perl/ruby shell 上运行

You might also see % python ez_setup.py, which also means the same thing

您可能还会看到% python ez_setup.py,这也意味着同样的事情

回答by Michael0x2a

When you open up command prompt in Windows, you'll see something like:

当您在 Windows 中打开命令提示符时,您会看到如下内容:

C:\Users\Michael0x2a\Blah> 

The $symbol is the equivalent in Linux-based systems.

$符号在基于 Linux 的系统中是等效的。

Whenever you see the $sign, simply ignore it and type in the rest of the line without modification.

每当您看到该$标志时,只需忽略它并输入该行的其余部分而无需修改。

回答by trm42

As the two previous answers told, $is the beginning of commandline prompt waiting for your input in Unix/Linux -systems. In Windows the similar example notation would be like

正如前两个答案所说,$命令行提示符的开始等待您在 Unix/Linux -systems 中的输入。在 Windows 中,类似的示例符号如下

C:\> python ez_setup.py

So you don't have to write the dollar sign. Just imagine the beginnings of Windows CMD or Powershell prompt in the beginning of line :)

所以你不必写美元符号。想象一下行首的 Windows CMD 或 Powershell 提示符的开头:)

You can read more discussion about the history of dollar sign from Superuser.

您可以从 Superuser阅读更多有关美元符号历史的讨论。