【问题标题】:Impossible to create a configuration file for an python application inside Google App Engine无法在 Google App Engine 中为 python 应用程序创建配置文件
【发布时间】: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


    【解决方案1】:
    [bucket]
    bucketname= octopus_storage
    

    【讨论】:

    • 非常感谢。问题已解决。代码和配置文件是正确的。配置文件在错误的目录中。
    猜你喜欢
    • 2018-12-07
    • 2017-07-28
    • 1970-01-01
    • 2017-05-21
    • 1970-01-01
    • 2012-11-19
    • 2018-05-29
    • 2019-12-15
    • 1970-01-01
    相关资源
    最近更新 更多