文章目录

  • Python命令行完整选项
  • sys.flag - Python启动命令行选项标志

Python命令行完整选项

https://blog.csdn.net/qq_43401808/article/details/88887356

sys.flag - Python启动命令行选项标志

这是一个只读的结构序列,保存并导出了启动Python时的命令行选项。

# Python 3.7.3
[tony@tony-controller bin]$ ./python3 --version
Python 3.7.3# 不指定任何选项启动Python
# 除了-R (hash_randomization)启用之外,其他选项皆默认关闭。
[tony@tony-controller bin]$ ./python3
Python 3.7.3 (default, Apr 25 2019, 09:22:47)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.flags
sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomization=1, isolated=0, dev_mode=False, utf8_mode=0)
>>> quit()# Python启动时,指定所有选项
# -v:打印出启动时所有的import
[tony@tony-controller bin]$ ./python3 -d -i -I -O -B -s -S -E -v -b -q -R -X dev -X utf8
import _frozen_importlib # frozen
import _imp # builtin
import '_thread' # <class '_frozen_importlib.BuiltinImporter'>
import '_warnings' # <class '_frozen_importlib.BuiltinImporter'>
import '_weakref' # <class '_frozen_importlib.BuiltinImporter'>
# installing zipimport hook
import 'zipimport' # <class '_frozen_importlib.BuiltinImporter'>
# installed zipimport hook
import '_frozen_importlib_external' # <class '_frozen_importlib.FrozenImporter'>
import '_io' # <class '_frozen_importlib.BuiltinImporter'>
import 'marshal' # <class '_frozen_importlib.BuiltinImporter'>
import 'posix' # <class '_frozen_importlib.BuiltinImporter'>
import _thread # previously loaded ('_thread')
import '_thread' # <class '_frozen_importlib.BuiltinImporter'>
import _weakref # previously loaded ('_weakref')
import '_weakref' # <class '_frozen_importlib.BuiltinImporter'>
import 'faulthandler' # <class '_frozen_importlib.BuiltinImporter'>
# /home/tony/python37/lib/python3.7/encodings/__pycache__/__init__.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/encodings/__init__.py
# code object from '/home/tony/python37/lib/python3.7/encodings/__pycache__/__init__.cpython-37.opt-1.pyc'
# /home/tony/python37/lib/python3.7/__pycache__/codecs.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/codecs.py
# code object from '/home/tony/python37/lib/python3.7/__pycache__/codecs.cpython-37.opt-1.pyc'
import '_codecs' # <class '_frozen_importlib.BuiltinImporter'>
import 'codecs' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc49e373898>
# /home/tony/python37/lib/python3.7/encodings/__pycache__/aliases.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/encodings/aliases.py
# code object from '/home/tony/python37/lib/python3.7/encodings/__pycache__/aliases.cpython-37.opt-1.pyc'
import 'encodings.aliases' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc49e38ea50>
import 'encodings' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc49e3effd0>
# /home/tony/python37/lib/python3.7/encodings/__pycache__/utf_8.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/encodings/utf_8.py
# code object from '/home/tony/python37/lib/python3.7/encodings/__pycache__/utf_8.cpython-37.opt-1.pyc'
import 'encodings.utf_8' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc49e3a4108>
import '_signal' # <class '_frozen_importlib.BuiltinImporter'>
# /home/tony/python37/lib/python3.7/encodings/__pycache__/latin_1.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/encodings/latin_1.py
# code object from '/home/tony/python37/lib/python3.7/encodings/__pycache__/latin_1.cpython-37.opt-1.pyc'
import 'encodings.latin_1' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc49e3a8210>
# /home/tony/python37/lib/python3.7/__pycache__/io.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/io.py
# code object from '/home/tony/python37/lib/python3.7/__pycache__/io.cpython-37.opt-1.pyc'
# /home/tony/python37/lib/python3.7/__pycache__/abc.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/abc.py
# code object from '/home/tony/python37/lib/python3.7/__pycache__/abc.cpython-37.opt-1.pyc'
import '_abc' # <class '_frozen_importlib.BuiltinImporter'>
import 'abc' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc49e3a8b58>
import 'io' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc49e3a8580>
# /home/tony/python37/lib/python3.7/__pycache__/warnings.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/warnings.py
# code object from '/home/tony/python37/lib/python3.7/__pycache__/warnings.cpython-37.opt-1.pyc'
# /home/tony/python37/lib/python3.7/__pycache__/re.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/re.py
# code object from '/home/tony/python37/lib/python3.7/__pycache__/re.cpython-37.opt-1.pyc'
# /home/tony/python37/lib/python3.7/__pycache__/enum.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/enum.py
# code object from '/home/tony/python37/lib/python3.7/__pycache__/enum.cpython-37.opt-1.pyc'
# /home/tony/python37/lib/python3.7/__pycache__/types.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/types.py
# code object from '/home/tony/python37/lib/python3.7/__pycache__/types.cpython-37.opt-1.pyc'
import 'types' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc49e3621b8>
import '_collections' # <class '_frozen_importlib.BuiltinImporter'>
import 'enum' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc49e348f78>
# /home/tony/python37/lib/python3.7/__pycache__/sre_compile.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/sre_compile.py
# code object from '/home/tony/python37/lib/python3.7/__pycache__/sre_compile.cpython-37.opt-1.pyc'
import '_sre' # <class '_frozen_importlib.BuiltinImporter'>
# /home/tony/python37/lib/python3.7/__pycache__/sre_parse.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/sre_parse.py
# code object from '/home/tony/python37/lib/python3.7/__pycache__/sre_parse.cpython-37.opt-1.pyc'
# /home/tony/python37/lib/python3.7/__pycache__/sre_constants.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/sre_constants.py
# code object from '/home/tony/python37/lib/python3.7/__pycache__/sre_constants.cpython-37.opt-1.pyc'
import 'sre_constants' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc49e3130b0>
import 'sre_parse' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc49e302528>
import 'sre_compile' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc49e36af78>
# /home/tony/python37/lib/python3.7/__pycache__/functools.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/functools.py
# code object from '/home/tony/python37/lib/python3.7/__pycache__/functools.cpython-37.opt-1.pyc'
import '_functools' # <class '_frozen_importlib.BuiltinImporter'>
# /home/tony/python37/lib/python3.7/collections/__pycache__/__init__.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/collections/__init__.py
# code object from '/home/tony/python37/lib/python3.7/collections/__pycache__/__init__.cpython-37.opt-1.pyc'
# /home/tony/python37/lib/python3.7/__pycache__/_collections_abc.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/_collections_abc.py
# code object from '/home/tony/python37/lib/python3.7/__pycache__/_collections_abc.cpython-37.opt-1.pyc'
import '_collections_abc' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc496c39dc0>
# /home/tony/python37/lib/python3.7/__pycache__/operator.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/operator.py
# code object from '/home/tony/python37/lib/python3.7/__pycache__/operator.cpython-37.opt-1.pyc'
import '_operator' # <class '_frozen_importlib.BuiltinImporter'>
import 'operator' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc496c45fd0>
# /home/tony/python37/lib/python3.7/__pycache__/keyword.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/keyword.py
# code object from '/home/tony/python37/lib/python3.7/__pycache__/keyword.cpython-37.opt-1.pyc'
import 'keyword' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc496bf87e8>
# /home/tony/python37/lib/python3.7/__pycache__/heapq.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/heapq.py
# code object from '/home/tony/python37/lib/python3.7/__pycache__/heapq.cpython-37.opt-1.pyc'
# extension module '_heapq' loaded from '/home/tony/python37/lib/python3.7/lib-dynload/_heapq.cpython-37m-x86_64-linux-gnu.so'
# extension module '_heapq' executed from '/home/tony/python37/lib/python3.7/lib-dynload/_heapq.cpython-37m-x86_64-linux-gnu.so'
import '_heapq' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc496bf7f78>
import 'heapq' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc496bf76e0>
import 'itertools' # <class '_frozen_importlib.BuiltinImporter'>
# /home/tony/python37/lib/python3.7/__pycache__/reprlib.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/reprlib.py
# code object from '/home/tony/python37/lib/python3.7/__pycache__/reprlib.cpython-37.opt-1.pyc'
import 'reprlib' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc496bf3e70>
import 'collections' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc496c11630>
import 'functools' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc49e31fc08>
import '_locale' # <class '_frozen_importlib.BuiltinImporter'>
# /home/tony/python37/lib/python3.7/__pycache__/copyreg.cpython-37.opt-1.pyc matches /home/tony/python37/lib/python3.7/copyreg.py
# code object from '/home/tony/python37/lib/python3.7/__pycache__/copyreg.cpython-37.opt-1.pyc'
import 'copyreg' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc4969a01b8>
import 're' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc49e343210>
import 'warnings' # <_frozen_importlib_external.SourceFileLoader object at 0x7fc49e3aec08>
>>> sys.flags
Traceback (most recent call last):File "<stdin>", line 1, in <module>
NameError: name 'sys' is not defined
>>> import sys
>>> sys.flags
sys.flags(debug=1, inspect=1, interactive=1, optimize=1, dont_write_bytecode=1, no_user_site=1, no_site=1, ignore_environment=2, verbose=1, bytes_warning=1, quiet=1, hash_randomization=1, isolated=1, dev_mode=True, utf8_mode=1)
>>>

【Python】Python3.7.3 - sys.flag 命令行选项标志结构序列相关推荐

  1. 《Python 黑帽子》学习笔记 - 命令行选项和参数处理 - Day 4

    在学习书中 netcat 代码的时候,发现其命令行选项和参数的处理存在一些小问题,由于调用 getopt 模块的 getopt() 函数时参数设置不当,会引起代码执行时获取不到参数值或引发异常.该问题 ...

  2. python add argument list_python模块介绍- argparse:命令行选项及参数解析

    #承接软件自动化实施与培训等gtalk:ouyangchongwu#gmail.com qq 37391319 博客: http://blog.csdn.net/oychw #版权所有,转载刊登请来函 ...

  3. python 基础命令-详解python常用命令行选项与环境变量

    一.命令行选项 1.解释器选项 python的解释器非常像unix的shell,在我们使用python的过程中,我们可以指定很多的选项. 比如,最常用的选项如下: python script.py 在 ...

  4. getopt:命令行选项、参数处理

    getopt:命令行选项.参数处理 2014-01-11 Posted by yeho 在写shell脚本时经常会用到命令行选项.参数处理方式,如: ./test.sh -f config.conf ...

  5. ccf命令行选项只能用c实现_CCF-201403-3-命令行选项

    问题描述 试题编号: 201403-3 试题名称: 命令行选项 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 请你写一个命令行分析程序,用以分析给定的命令行里包含哪些选项.每 ...

  6. 命令行选项解析函数(C语言):getopt()和getopt_long()

    上午在看源码项目 webbench 时,刚开始就被一个似乎挺陌生函数 getopt_long() 给卡住了,说实话这函数没怎么见过,自然不知道这哥们是干什么的.于是乎百度了一番,原来是处理命令行选项参 ...

  7. gcc命令行选项说明

    GCC 支持许多命令行选项,这些选项控制将运行时检测添加到其通常生成的代码中.例如,检测的一个目的是收集分析统计信息,以用于查找程序热点.代码覆盖率分析或按配置文件优化.另一类程序检测是添加运行时检查 ...

  8. 命令行选项解析函数(C语言):getopt()和getopt_long()【转】

    (转自:https://www.cnblogs.com/chenliyang/p/6633739.html) 上午在看源码项目 webbench 时,刚开始就被一个似乎挺陌生函数 getopt_lon ...

  9. 命令行选项解析函数:getopt()

    1.定义: int getopt(int argc, char * const argv[], const char *optstring); 2.描述: getopt是用来解析命令行选项参数的,但是 ...

最新文章

  1. 常用javascript函数
  2. Exchange DAG备份恢复(六)---通过Windows Server Backup对单个邮箱进行恢复
  3. poj1061-青蛙的约会
  4. Factorial Trailing Zeroes
  5. web项目中遇到的Maven包依赖冲突问题解决
  6. Linux / 守护进程
  7. GitHub for windows使用教程(三) 团队协作流程
  8. Java JVM 汇编代码入门 GitChat链接
  9. 炒房客共识:深圳楼市要撑不住了
  10. UI网页头部设计模板素材|这么多讲究,你知道吗?
  11. 数据:以太坊2.0合约余额新增2944 ETH
  12. 女生在施工单位项目部上工作,是怎样一种体验?
  13. python 学习DAY12
  14. [leetcode]62. 不同路径
  15. PHP问题Parse error: syntax error, unexpected end of file in
  16. 敏捷开发模式下SDL实践
  17. SPSS T检测原理及结果分析
  18. 编译原理学习之:有限状态机(Finate-state Automaton)
  19. [POI2009]Lyz
  20. 卷积、线性时不变系统、因果系统

热门文章

  1. 快速行进算法(fast_marching_kroon)的matlab代码
  2. dataframe格式的数据处理
  3. Apollo使用指南(一)普通应用接入指南
  4. MongoDB数据库操作---mongoose操作
  5. mongodb删除文档
  6. 数组中的两个常见异常
  7. micropython stm32f429_[MicroPython]STM32F407开发板驱动OLED液晶屏
  8. element table多选只能选中当前页数据_关于“列表多选”操作流的小思考
  9. pca主成分分析_降维:主成分分析(PCA)
  10. 持续集成(Continuous integration)