Python语法

os模块

os.path.dirname() 返回路径中的目录路径

>>> os.path.dirname('C:\Windows\System32\drivers\etc\hosts')
'C:\\Windows\\System32\\drivers\\etc'
View Code

os.path.abspath() 返回路径的规范化的绝对路径

>>> os.path.abspath('C:\Windows\System32\drivers\etc\hosts')
'C:\\Windows\\System32\\drivers\\etc\\hosts'
View Code

os.environ[] 获取系统环境变量

>>> os.environ['PATH']
'C:\\Program Files (x86)\\Common Files\\NetSarang;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;D:\\Program files\\Python27;C:\\Program Files\\Java\\jdk1.8.0_51\\bin;C:\\Go\\bin\\;D:\\Program files\\calibre\\;C:\\Go\\bin;C:\\Go;C:\\Program Files\\ThinkPad\\Bluetooth Software\\;C:\\Program Files\\ThinkPad\\Bluetooth Software\\syswow64;D:\\Program files\\Python35;D:\\Program Files\\TortoiseSVN\\bin;d:\\Program Files\\Bandizip\\7z;C:\\Go;D:\\Program files\\Python35;D:\\Program files\\Python35\\lib\\site-packages\\pywin32_system32;.;;D:\\Program files\\Python35\\lib\\site-packages\\pywin32_system32'
View Code

 

virtualenv

Windows下

  1.创建虚拟环境

  在CMD切换到virtualenv安装路径(如果将安装路径添加的环境变量中则无须切换安装路径)

  C:\Users\Administrator>cd D:\Program files\Python35\Scripts

  D:\Program files\Python35\Scripts>virtualenv.exe F:\Flask_Dev_20181120_ENV

  2.环境激活

  切换到安装目录下,执行以下命令

  F:\Flask_Dev_20181120_ENV\Scripts>activate

  

  

posted @ 2018-11-17 10:25  村西崔二  阅读(113)  评论(0编辑  收藏  举报