首页 > 编程语言 >python命令行参数

python命令行参数

时间:2024-03-18 15:57:23浏览次数:31  
标签:Python help python also 参数 命令行 print --

python帮助文档

Launcher arguments:
-2     : Launch the latest Python 2.x version
-3     : Launch the latest Python 3.x version
-X.Y   : Launch the specified Python version

The above default to an architecture native runtime, but will select any
available. Add a "-32" to the argument to only launch 32-bit runtimes,
or add "-64" to omit 32-bit runtimes (this latter option is deprecated).

To select a specific runtime, use the -V: options.

-V:TAG         : Launch a Python runtime with the specified tag
-V:COMPANY/TAG : Launch a Python runtime from the specified company and
                 with the specified tag

-0  --list       : List the available pythons
-0p --list-paths : List with paths

If no options are given but a script is specified, the script is checked for a
shebang line. Otherwise, an active virtual environment or global default will
be selected.

See https://docs.python.org/using/windows.html#python-launcher-for-windows for
additional configuration.

The following help text is from Python:
usage: C:\Users\Radsim\AppData\Local\Programs\Python\Python312\python.exe [option] ... [-c cmd | -m mod | file | -] [arg] ...
Options (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 import; also PYTHONDONTWRITEBYTECODE=x
-c cmd : program passed in as string (terminates option list)
-d     : turn on parser debugging output (for experts only, only works on
         debug builds); also PYTHONDEBUG=x
-E     : ignore PYTHON* environment variables (such as PYTHONPATH)
-h     : print this help message and exit (also -? or --help)
-i     : inspect interactively after running script; forces a prompt even
         if stdin does not appear to be a terminal; also 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 statements; add .opt-1 before
         .pyc extension; also PYTHONOPTIMIZE=x
-OO    : do -O changes and also discard docstrings; add .opt-2 before
         .pyc extension
-P     : don't prepend a potentially unsafe path to sys.path; also PYTHONSAFEPATH
-q     : don't print version and copyright messages on interactive startup
-s     : don't add user site directory to sys.path; also PYTHONNOUSERSITE
-S     : don't imply 'import site' on initialization
-u     : force the stdout and stderr streams to be unbuffered;
         this option has no effect on stdin; 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 control; arg 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
--check-hash-based-pycs always|default|never:
         control how Python invalidates hash-based .pyc files
--help-env      : print help about Python environment variables and exit
--help-xoptions : print help about implementation-specific -X options and exit
--help-all      : print complete help information and exit
Arguments:
file   : program read from script file
-      : program read from stdin (default; interactive mode if a tty)
arg ...: arguments passed to program in sys.argv[1:]

中文解释(按照使用优先级)
1)-i
用法

py -i *.py

运行脚本之后进入交互,交互过程保留工作空间,可以获取工作空间的变量。
2)

标签:Python,help,python,also,参数,命令行,print,--
From: https://www.cnblogs.com/luozyblog/p/18080537

相关文章

  • Python中那些简单又好用的特性和用法
    Python中那些简单又好用的特性和用法Python作为我的主力语言帮助我开发了许多DevOps运维自动化系统,这篇文章总结几个我在编写Python代码过程中用到的几个简单又好用的特性和用法,这些特性和用法可以帮助我们更高效地编写Python代码1.链式比较x=5y=10z=15ifx<y<z......
  • python 面向对象(三)magic methods
    magicmethods就是双下划线方法AsaPythondeveloperwhowantstoharnessthepowerofobject-orientedprogramming,you’lllovetolearnhowtocustomizeyourclassesusingspecialmethods,alsoknownasmagicmethodsordundermethods.Aspecialmethodisa......
  • Python实现HTTPS网站证书过期监控及更新
    Python实现HTTPS网站证书过期监控及更新当前HTTP逐渐被大众所抛弃,HTTPS正在成为互联网上的主流。前段时间我们维护的一个HTTPS证书即将过期,由于多云环境比较复杂,团队小伙伴在替换更新证书的过程中出现疏漏,导致有一个域名证书没有及时更新,影响了系统可用性,为了杜绝这种问题再次发......
  • python + xlwings 操作Excel,复制粘贴保留格式
    在使用python处理Excel时,需求是要保留Excel内的格式(例如字体,大小,背景颜色,函数公式....),试了其它几个库,都没达到效果,偶然发现了xlwings,可以达到我所需要的效果。importxlwingsasxwfromxlwings.constantsimportPasteType打开Excel文件workbook=xw.Book('example.xlsx')......
  • 【Python使用】嘿马头条完整开发md笔记第2篇:数据库,作用【附代码文档】
    嘿马头条项目从到完整开发笔记总结完整教程(附代码资料)主要内容讲述:课程简介,ToutiaoWeb虚拟机使用说明,Pycharm远程开发,产品与开发,数据库1产品介绍,2原型图与UI图,3技术架构,4开发。OSS对象存储,七牛云存储,CDN,缓存。缓存,缓存架构,缓存数据,缓存有效期与淘汰策略,缓存模式缓存数据的......
  • python pytest.mark
    pytest.mark是pytest测试框架中的一个功能,它允许你为测试用例和测试夹具(fixtures)添加元数据(或称为“标记”)。这些标记可以用于各种目的,例如选择性地运行特定的测试用例集,跳过某些测试用例,或者为测试用例添加额外的信息。pytest.mark主要有以下几种用法:为测试用例添加标记:你......
  • FAN3224TMX门极驱动器中文资料PDF数据手册引脚图参数价格图片功能特性
    产品概述:FAN3223-25系列双4A门极驱动器以较短的开关间隔提供高峰值电流脉冲,用于在低侧开关应用中驱动N沟道增强模式MOSFET。该驱动器提供TTL或CMOS输入阈值。内部电路将输出保持在低电平,直到电源电压处于运行范围内,从而提供欠压锁定功能。另外,这些驱动器具有匹配的......
  • NCV1117ST50T3G线性稳压器芯片中文资料规格书PDF数据手册引脚图图片价格参数
    产品概述:NCP1117系列为低压差(LDO)正向线性电压稳压器,能够提供超过1.0A的输出电流,800mA时温度范围内最大压差为1.2V。这一系列包括八个固定输出电压:1.5V、1.8V、2.0V、2.5V、2.85V、3.3V、5.0V和12V,保持稳压没有最低负载要求。另外还包括可调节输出版本,使用两个外部电阻,实现从......
  • python @pytest.fixture示例及用法
    [email protected]示例及用法@pytest.fixture是pytest测试框架中的一个非常有用的功能,它允许你定义可以在多个测试用例之间共享的设置和清理代码。通过使用fixture,你可以减少重复的代码,并使得测试用例更加清晰和模块化。下面是一个简单的示例,展示了如何使用@pytest.fi......
  • [983] Add a notification after finishing the Python script
    ref:HowtoimplementaPythondesktopnotifierusingtheplyermoduleYoucangenerateanotificationafteryourPythoncodefinishesexecutingusingvariousmethods.Hereareafewoptions:UsingPlyer(Cross-Platform):Installthe plyer libraryusi......