推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
SiPychmo
V2EX  ›  Python

新人求助!! Pycharm 环境配置问题,以及 flask 路由中 methods 参数

  •  
  •   SiPychmo · Jan 11, 2019 · 1474 views
    This topic created in 2684 days ago, the information mentioned may be changed or developed.
    1,
    本机环境:
    anaconda3,其 python 版本是 3.7
    python3.5
    pycharm 社区版 2018

    Pycharm Setting 里 project interpreter 明明已经选择了 anaconda3,也安装了 flask 模块,为什么编译的时候还是报错没有 flask 模块 ( ImportError: No module named 'flask' ) 。
    反倒在 cmd 里 pip install flask (即在 python3.5 安装了 flask )之后就可以了,那是不是意味 pycharm 的运行环境指向了 python3.5 ,但是我明明以及在 project interpreter 已经选择了 anaconda3 啊!

    2,
    from flask import Flask
    app = Flask(__name__)
    @app.route('/',methods=['post']) #methods=['get','post']
    def hello_world():
    return 'Hllo1'
    if __name__ == '__main__':
    app.run()

    这是源码,运行会报错 Method Not Allowed The method is not allowed for the requested URL.
    只要改成 methods=['get','post'] 就没问题。
    为什么?是不是我运行环境的问题,请大家帮忙试试,源码只有几行而已
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5256 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 08:56 · PVG 16:56 · LAX 01:56 · JFK 04:56
    ♥ Do have faith in what you're doing.