读写配置文件的简单示例程序:
import os
import myfunc as mf
import configparser as cp
conf=cp.ConfigParser()
file=os.path.realpath(__file__)
print('%s %s' %(type(file), file))
cur_path=os.path.dirname(os.path.realpath(__file__))
parentpath=os.path.dirname(cur_path)
print('%s %s' %(type(cur_path), cur_path))
print('%s %s' %(type(parentpath), parentpath))
grandpath=os.path.dirname(parentpath)
print('%s %s' %(type(grandpath), grandpath))
config_path=os.path.join(grandpath,'config.ini')
conf.read(config_path, 'utf-8')
pdf_root=conf.get('root', 'fatherpdfroot')
print('my father %s' % pdf_root)
print('call it......')
dubi=mf.funct(' input var-yes he..............')
print('end ...............................%s' % dubi)