|
在线上写了一个脚本,要定义一些键值对,索性放在property文件里面:
引用
dress=30604683
scenery=30605417
diy=30599014
dessert=13950861
office=30599116
zakka=29930202
trave=12954996
chinese=21177698
jieke=14738565
tableware=10050474
上网搜索了一下python有对ini文件的支持,python内部有一个ConfigParser类来支持ini 文件的读写。
首先,需要在数据文件前面加上一个标记,python里面叫sections,这里叫[board]
引用
[board]
dress=30604683
scenery=30605417
diy=30599014
dessert=13950861
office=30599116
zakka=29930202
trave=12954996
chinese=21177698
jieke=14738565
tableware=10050474
import ConfigParser
import string, os, sys
cf = ConfigParser.ConfigParser()
cf.read("test.conf")
s = cf.sections()
print 'section:', s
for board in cf.items('board'):
print board[0]+'='+board[1]
参考:
http://www.cnblogs.com/sislcb/archive/2008/11/25/1340587.html
http://blog.csdn.net/wayne92/article/details/1802092 |
|
|