无法在 Google App Engine 内为 python 应用程序创建配置文件
我尝试创建一个配置文件,在其中可以存储常量。
每当我尝试使用 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 位于错误的目录中。
I try to create a configuration file, where I can store constants.
Whenever I try with ConfigParser, I get an error
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')
...
How can I fix this?
===============================
The problem is fixed. The code was correct, but simple.cfg was in the wrong directory.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)