import python 配置文件,importpython,这段代码演示使用impo
import python 配置文件,importpython,这段代码演示使用impo
这段代码演示使用import读入Python格式的配置文件。
# To run this code, create a python file, say config.py, with a sample parameter # called sample_param. import osimport sysdef main(): if len(sys.argv) == 1: print "usage: %s config_file" % os.path.basename(sys.argv[0]) sys.exit(2) config_file = os.path.basename(sys.argv[1]) if config_file[-3:] == ".py": config_file = config_file[:-3] data_config = __import__(config_file, globals(), locals(), []) print data_config.sample_parammain()
相关内容
- Python 获取目录下的文件列表与内容,python获取,下面的
- Python使用socket类获取服务器IP地址,pythonsocket,Python 获取
- python源代码语法高亮输出,python源代码高亮,## {{{ http
- unix subprocess wrapper,subprocesswrapper,I have used
- Python+MongDB实现短链接,pythonmongdb实现,实现任意数制变
- Automatic ref-count management in C++ using a smart ptr,ref-countpt
- python判断文件和文件夹是否存在,python判断,python判断文
- python使用urllib访问url,pythonurlliburl,python使用urll
- Python使用split使用多个字符分隔字符串,pythonsplit,Pyth
- python使用gc.get_objects()查看运行时对象,,从python2.2开始
评论关闭