2015-02-23 121 views
0

我在写入配置文件时遇到问题。我有两个Python脚本可以读写同一个文件。问题是当我从一个脚本写入它时,它会覆盖另一个脚本中的内容。ConfigParser覆盖配置文件的内容

这里是我的代码:

authfile = "Users/.ahs" # .ahs is a hidden file 
config = ConfigParser.ConfigParser() 
tmpfile = open(authfile, "w+") 
config.add_section(s) 
config.set(s, k, t) 
config.write(tmpfile) 
tmpfile.close() 

回答