擅长:python、mysql、java
<p>您需要在文件中添加一个部分:</p>
<pre><code>[My Section]
path1 = D:\test1\first
path2 = D:\test2\second
path3 = D:\test2\third
</code></pre>
<p>然后,读取属性:</p>
<pre><code>import ConfigParser
config = ConfigParser.ConfigParser()
config.readfp(open(r'abc.txt'))
path1 = config.get('My Section', 'path1')
path2 = config.get('My Section', 'path2')
path3 = config.get('My Section', 'path3')
</code></pre>