Python请求-发布json

时间:2020-08-22 16:22:08

标签: python json sqlite post python-requests

邮政编码

import requests

form = {
    "token": 123,
    "discordid": 330421170186879007
}

data = requests.post('sample/dir', json=form)

收到验证码

@app.route('/dir', methods=['POST'])
def post():
    Discordid = request.form.get("discordid")
    token = request.form.get("token")
    cur.execute("UPDATE table SET Token = (?) WHERE DiscordID = (?);", (Discordid, token,))
    conn.commit()
    print(token, Discordid)
    return ('', 204)

在接收控制台上,我得到的打印内容为无,None

为什么我得到None的不和谐,令牌以及如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

尝试

class GetRandomCity extends Weather {
    constructor(city) {
        super();
        this.city = city;
    }

    makeRandom() {
       //code
    };

    init() {
        this.makeRandom().then(city => {
            this.getCoordinates(city)
        }).then(coords => {
            return this.getWeatherForecast(coords);
        }).then((forecast) => {
            const { currently, daily } = forecast;
            this.renderForecastInfo(currently, daily);
        });
    }
}

const w1 = new GetRandomCity(['Paris', 'Minsk', 'Madrid', 'Chikago']);

也许在

data = requests.post('sample/dir', data=form)

您需要更改参数的顺序吗?