1. python中獲取常用變量的一個方法: ``` import os JS_ADDRESS = os.environ.get("PALM_JS_ADDRESS") print(os.environ.get("PALM_JS_ADDRESS")) ``` 2. Python之獲取平台和操作系統信息(platform模塊) ``` import platform platform.platform() #獲取操作系統名稱及版本號,'Linux-3.13.0-46-generic-i686-with-Deepin-2014.2-trusty' platform.system() #獲取操作系統名稱,'Linux' platform.version() #獲取操作系統版本號,'#76-Ubuntu SMP Thu Feb 26 18:52:49 UTC 2015' platform.architecture() #獲取操作系統的位數,('32bit', 'ELF') platform.machine() #計算機類型,'i686' platform.node() #計算機的網絡名稱,'XF654' platform.processor() #計算機處理器信息,''i686' platform.uname() #包含上面所有的信息匯總,('Linux', 'XF654', '3.13.0-46-generic', '#76-Ubuntu SMP Thu Feb 26 18:52:49 UTC 2015', 'i686', 'i686') 示例: LOG_PATH = '/data/logs/' if platform.system().lower() == 'windows': LOG_PATH = 'E:/log/' if not os.path.exists(LOG_PATH): os.mkdir(LOG_PATH) elif platform.system().lower() == 'linux': if not os.path.exists(LOG_PATH): os.mkdir(LOG_PATH) else: if not os.path.exists(LOG_PATH): os.mkdir(LOG_PATH)