怎么在命令行窗口运行python -V?

Python019

怎么在命令行窗口运行python -V?,第1张

命令行运行python -V的步骤如下:

1、在win10系统上使用组合键WIN + R ,启动运行窗口,在运行窗口中输入cmd ,点击确定按钮

2、启动一个cmd命令行窗口

3、在cmd命令行窗口中输入python -V,有下图所示的回显,说明python3的环境已经安装到电脑上了,可以运行python脚本。

python -V的功能如下:

python -V (大写)与 python --version 功能相同,是将 python 版本打印并退出 python。

环境变量没有设置成功。需要重新设置环境变量。右键点击"我的电脑"->属性->高级系统设置->环境变量,在系统变量栏目中,找到Path,双击编辑后,添加刚才安装python的路径,添加完环境变量后,再输入命令python–v验证即可。python-v是以一种特殊模式进入python,该模式下每次有模块被初始化就会打印相应信息,展示载入的模块名或者内置模块。

首先这个命令不是在python交互环境下运行的,其次需要使用python -V要大写的V才可以输出版本号,如下:

其它命令说明:

C:\>python --help

usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...

Options and arguments (and corresponding environment variables):

-b     : issue warnings about str(bytes_instance), str(bytearray_instance)

and comparing bytes/bytearray with str. (-bb: issue errors)

-B     : don't write .pyc files on importalso PYTHONDONTWRITEBYTECODE=x

-c cmd : program passed in as string (terminates option list)

-d     : debug output from parseralso PYTHONDEBUG=x

-E     : ignore PYTHON* environment variables (such as PYTHONPATH)

-h     : print this help message and exit (also --help)

-i     : inspect interactively after running scriptforces a prompt even

if stdin does not appear to be a terminalalso PYTHONINSPECT=x

-I     : isolate Python from the user's environment (implies -E and -s)

-m mod : run library module as a script (terminates option list)

-O     : remove assert and __debug__-dependent statementsadd .opt-1 before

.pyc extensionalso PYTHONOPTIMIZE=x

-OO    : do -O changes and also discard docstringsadd .opt-2 before

.pyc extension

-q     : don't print version and copyright messages on interactive startup

-s     : don't add user site directory to sys.pathalso PYTHONNOUSERSITE

-S     : don't imply 'import site' on initialization

-u     : force the binary I/O layers of stdout and stderr to be unbuffered

stdin is always bufferedtext I/O layer will be line-buffered

also PYTHONUNBUFFERED=x

-v     : verbose (trace import statements)also PYTHONVERBOSE=x

can be supplied multiple times to increase verbosity

-V     : print the Python version number and exit (also --version)

when given twice, print more information about the build

-W arg : warning controlarg is action:message:category:module:lineno

also PYTHONWARNINGS=arg

-x     : skip first line of source, allowing use of non-Unix forms of #!cmd

-X opt : set implementation-specific option

file   : program read from script file

-      : program read from stdin (defaultinteractive mode if a tty)

arg ...: arguments passed to program in sys.argv[1:]