os.environ模块

Posted jiangzongyou

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了os.environ模块相关的知识,希望对你有一定的参考价值。

os.environ是用来获取当前操作系统的一些基本信息的模块

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MxShop.settings") # 给当前系统信息添加一个键值对
print(os.environ)
print(type(os.environ))
environ({‘ALLUSERSPROFILE‘: ‘C:\ProgramData‘, ‘APPDATA‘: ‘C:\Users\Administrator\AppData\Roaming‘,
‘COMMONPROGRAMFILES‘: ‘C:\Program Files\Common Files‘,
‘COMMONPROGRAMFILES(X86)‘: ‘C:\Program Files (x86)\Common Files‘,
‘COMMONPROGRAMW6432‘: ‘C:\Program Files\Common Files‘, ‘COMPUTERNAME‘: ‘JZY‘,
‘COMSPEC‘: ‘C:\Windows\system32\cmd.exe‘, ‘DRIVERDATA‘: ‘C:\Windows\System32\Drivers\DriverData‘,
‘FPS_BROWSER_APP_PROFILE_STRING‘: ‘Internet Explorer‘, ‘FPS_BROWSER_USER_PROFILE_STRING‘: ‘Default‘,
‘HOMEDRIVE‘: ‘C:‘, ‘HOMEPATH‘: ‘\Users\Administrator‘, ‘IDEA_INITIAL_DIRECTORY‘: ‘C:\Windows\system32‘,
‘LOCALAPPDATA‘: ‘C:\Users\Administrator\AppData\Local‘, ‘LOGONSERVER‘: ‘\\JZY‘,
‘NUMBER_OF_PROCESSORS‘: ‘8‘, ‘OS‘: ‘Windows_NT‘,
‘PATH‘: ‘C:\PythonRelated\mysql-5.6.45-winx64\bin;C:\Python27\Scripts;C:\Python27\;C:\Python36\Scripts\;C:\Python36\;C:\Python37\Scripts;C:\Python37;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\PythonRelated\Git\cmd;C:\PythonRelated\nodejs\;C:\Python37\Scripts\;C:\Python37\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;;C:\PythonRelated\PyCharm 2019.2.3\bin;;C:\Users\Administrator\AppData\Roaming\npm‘,
‘PATHEXT‘: ‘.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW‘, ‘PROCESSOR_ARCHITECTURE‘: ‘AMD64‘,
‘PROCESSOR_IDENTIFIER‘: ‘Intel64 Family 6 Model 60 Stepping 3, GenuineIntel‘, ‘PROCESSOR_LEVEL‘: ‘6‘,
‘PROCESSOR_REVISION‘: ‘3c03‘, ‘PROGRAMDATA‘: ‘C:\ProgramData‘, ‘PROGRAMFILES‘: ‘C:\Program Files‘,
‘PROGRAMFILES(X86)‘: ‘C:\Program Files (x86)‘, ‘PROGRAMW6432‘: ‘C:\Program Files‘,
‘PSMODULEPATH‘: ‘C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules‘,
‘PUBLIC‘: ‘C:\Users\Public‘, ‘PYCHARM‘: ‘C:\PythonRelated\PyCharm 2019.2.3\bin;‘,
‘PYCHARM_DISPLAY_PORT‘: ‘63342‘, ‘PYCHARM_HOSTED‘: ‘1‘, ‘PYTHONIOENCODING‘: ‘UTF-8‘,
‘PYTHONPATH‘: ‘G:\PycharmProjects\Jzy;C:\PythonRelated\PyCharm 2019.2.3\helpers\pycharm_matplotlib_backend;C:\PythonRelated\PyCharm 2019.2.3\helpers\pycharm_display‘,
‘PYTHONUNBUFFERED‘: ‘1‘, ‘SESSIONNAME‘: ‘Console‘, ‘SYSTEMDRIVE‘: ‘C:‘, ‘SYSTEMROOT‘: ‘C:\Windows‘,
‘TEMP‘: ‘C:\Users\ADMINI~1\AppData\Local\Temp‘, ‘TMP‘: ‘C:\Users\ADMINI~1\AppData\Local\Temp‘,
‘USERDOMAIN‘: ‘JZY‘, ‘USERDOMAIN_ROAMINGPROFILE‘: ‘JZY‘, ‘USERNAME‘: ‘Administrator‘,
‘USERPROFILE‘: ‘C:\Users\Administrator‘, ‘WINDIR‘: ‘C:\Windows‘,
‘WORKON_HOME‘: ‘C:\PythonRelated\Python37_Envs‘,
     ‘DJANGO_SETTINGS_MODULE‘: ‘MxShop.settings‘}) # 这就是刚刚的default加进去的
<class ‘os._Environ‘>

 

 

转载自: https://blog.csdn.net/qq_25680531/article/details/80922783

---  over  ---

以上是关于os.environ模块的主要内容,如果未能解决你的问题,请参考以下文章

os.environ.get()的用法

os 模块

二. python的os模块

python中os模块的一些方法

OS模块的应用

OS模块的应用