2006年11月01日 星期三 11:23
ÎҵĴúÂëÈçÏ£¬ÎÒµÄoptionΪ´óд×Öĸ£¬Ð´½øÈ¥±ä³ÉСд£¬Ôõô»ØÊ£¿
Ö¸µãһϣ¬Ð»Ð»£¡
def add_opt(file, sec, opt, val):
config = ConfigParser.ConfigParser()
try:
config.readfp(open(file))
except IOError, x:
print x
sys.exit(1)
try:
print sec,opt,val
config.set(sec, opt, val)
except ConfigParser.NoSectionError, y:
print y
sys.exit(1)
# set ºó»¹ÐèÊÖ¶¯±£´æ
fp=open(file, "w")
config.write(fp)
fp.close()
print "add opt", opt, "succ"
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20061101/0f758610/attachment.htm
2006年11月01日 星期三 12:18
On 11/1/06, 王明 <mingwang在iflytek.com> wrote: > 我的代码如下,我的option为大写字母,写进去变成小写,怎么回事? [...] > config = ConfigParser.ConfigParser() [...] ConfigParser就是把所有option转成小写处理的。看optionxform方法。
Zeuux © 2025
京ICP备05028076号