我正在尝试将字典的内容写入(然后读入)到 ConfigParser,并且我相信我根据文档正确地执行了此操作,但似乎无法使其正常工作。有人可以帮忙吗?
import ConfigParser
parser = ConfigParser.ConfigParser()
parser['User_Info'] = {"User1-votes":"36","User1-gamestart":"13232323","User2-votes":"36","User2-gamestart":"234234234","User3-votes":"36","User3-gamestart":"13232323"}
Traceback (most recent call last): File "<stdin>", line 1, in
<module> AttributeError: ConfigParser instance has no attribute '__setitem__'
我正在寻找的是有一个我可以更新的字典,最后写入一个配置文件,所以它看起来像:
[User_Info]
User1-gamestart = 13232323
User3-votes = 36
User2-votes = 36
User1-votes = 36
User2-gamestart = 234234234
User3-gamestart = 13232323