小编muh*_*med的帖子

谷歌应用引擎dev_appserver.py问题

我刚开始使用谷歌应用引擎,我在谷歌应用引擎上关注了基本的hello world示例.

https://developers.google.com/appengine/docs/python/gettingstartedpython27/helloworld

在helloworld文件夹中创建了这两个文件.

我不想使用GUI,我更喜欢使用mac终端来使用这个应用程序.我想在我的本地主机localhost:80上通过终端启动此应用程序.

我在本地运行我的基本helloworld应用程序

$ dev_appserver.py helloworld.但是我得到了这个错误.

Traceback (most recent call last):
  File "/usr/local/bin/dev_appserver.py", line 184, in <module>
    _run_file(__file__, globals())
  File "/usr/local/bin/dev_appserver.py", line 180, in _run_file
    execfile(script_path, globals_)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 727, in <module>
    main()
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 720, in main
    dev_server.start(options)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 554, in start
    options.yaml_files)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 556, in __init__
    module_configuration = ModuleConfiguration(yaml_path)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 82, in __init__
    self._yaml_path)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 271, in _parse_configuration
    with open(configuration_path) as f:
IOError: [Errno 2] …
Run Code Online (Sandbox Code Playgroud)

python google-app-engine

8
推荐指数
2
解决办法
1万
查看次数

有人可以通过这个Python代码并向我解释

months = ['January',
          'February',
          'March',
          'April',
          'May',
          'June',
          'July',
          'August',
          'September',
          'October',
          'November',
          'December']

def valid_month(month):
    if month:
        cap_month = month.capitalize()
        if cap_month in months:
            return cap_month
Run Code Online (Sandbox Code Playgroud)

所以上面是创建月份列表的python代码,基本上打印用户输入的内容,如果它是有效的月份.上面的代码很好.

下面是另一个类似于上面的版本,但我想更好或更用户友好.但我不确定这是如何工作的我没有看到这种方式的python词典可以有人通过这个代码并解释给我,非常感谢我.

months_abbvs = dict((m[:3].lower(), m) for m in months)

def valid_month(month):
    if month:
        short_month = month[:3].lower()
        return month_abbvs.get(short_month)
Run Code Online (Sandbox Code Playgroud)

python

3
推荐指数
1
解决办法
180
查看次数

标签 统计

python ×2

google-app-engine ×1