我的服務器中有這些包:
from flask import (
Flask,
request,
make_response,
send_from_directory,
send_file,
render_template,
redirect,
url_for,
current_app,
)
import json
import os
import subprocess
import sys
這條線運行良好:data = request.get_json()
然后我不得不添加更多的包:
import requests
from urllib import request
from urllib.parse import urlencode
現在我在該行中收到此錯誤:
AttributeError: module 'urllib.request' has no attribute 'get_json'
有些東西壞了,我不知道如何找到它。
uj5u.com熱心網友回復:
同一個名字不能有兩個定義。如果你這樣做
import request
from urllib import request
thenrequest現在指的是urllib.request,而不是request模塊,因為第二個import重新定義了名稱。
將第二個更改為
import urllib
然后用于urllib.request參考該模塊。request本身仍將參考該request模塊,因此request.get_json()將繼續作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/427430.html
標籤:Python python-3.x 烧瓶 要求 包裹
上一篇:通過存盤在物件中的名稱執行函式
