Python运行报错 'utf-8' codec can't decode byte 0xcb in position 0
迷茫
迷茫 2017-04-18 09:56:39
0
2
996
from flask import Flask
from flask import request
app=Flask(__name__)
@app.route('/',methods=['GET','POST'])
def home():
    return '<h1>home</h1>'
@app.route('/signin',methods=['GET'])
def signin_form():
    return '''<form action="/signin" method="post">
              <p><input name="username"></p>
              <p><input name="password" type="password"></p>
              <p><button type="submit">SINGN IN</button></p>
            </form>'''
@app.route('/signin',methods=['POST'])
def signin():
    if request.form['username']=='admin' and request.form['password']=='123':
        return '<h2>hello admin</h2>'
    return '<h3>bad username or password</h3>'
if __name__=='__main__':
    app.run()
迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

membalas semua(2)
Ty80

Untuk isu pengekodan fail, tambahkan kod berikut pada baris pertama fail python:

#coding: utf-8

刘奇

#coding: utf-8

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!