【发布时间】:2011-05-02 07:31:13
【问题描述】:
我尝试创建一个配置文件,我可以在其中存储常量。
每当我尝试使用 ConfigParser 时,都会出现错误
Traceback (most recent call last):
File "/home/baun/google_appengine/google/appengine/ext/webapp /__init__.py", line 511, in __call__
handler.get(*groups)
File "/home/baun/workspace/octopuscloud/s3/S3.py", line 138, in get
test = parser.get('bucket', 'bucketname')
File "/usr/lib/python2.5/ConfigParser.py", line 511, in get
raise NoSectionError(section)
NoSectionError: No section: 'bucket'
simple.cfg:
[bucket]
bucketname: 'octopus_storage'
s3.py:
...
from ConfigParser import SafeConfigParser
parser = SafeConfigParser()
parser.read('simple.cfg')
...
# Get values from the config file
test = parser.get('bucket', 'bucketname')
...
我该如何解决这个问题?
=================================
问题已解决。代码是正确的,但 simple.cfg 位于错误的目录中。
【问题讨论】:
标签: python google-app-engine configuration configuration-files configparser