Python设置

设置当前工作目录:import os ;os.chdir('要设置的当前目录')
 sys.path.append:添加模块的搜索路径
 sys.path:返回模块的搜索路径
 如果要在python2的py文件里面写中文,
 则必须要添加一行声明文件编码的注释,否则python2会默认使用ASCII编码。
 # -*- coding:utf-8 -*-
 
 在Python中运行Python文件:
 方法一:
 import os
 os.system("python filename")
 方法二:
 execfile('xx.py')
 “路径是绝对路径”

posted on 2017-02-07 09:29  知止而后有定  阅读(226)  评论(0)    收藏  举报

导航