简体   繁体   English

AttributeError: 'tuple' object 在 Postman 中使用 POST 请求时没有属性 'get'

[英]AttributeError: 'tuple' object has no attribute 'get' while using POST request in Postman

I'm trying to use request.get_json() to add nodes from JSON data to a set.我正在尝试使用 request.get_json() 将来自 JSON 数据的节点添加到一个集合中。

@app.route('/connect_node', methods = ['POST'])

def connect_node():
    json = request.get_json()
    nodes = json.get('nodes')              
    if nodes is None:
        return "No node", 400 

The snapshot of the Postman POST request Postman POST请求截图

The error I'm getting in Spyder(Python 3.9):我在 Spyder(Python 3.9)中遇到的错误:

line 178, in connect_node
nodes = json.get(nodes)
AttributeError: 'tuple' object has no attribute 'get' 

I'm assuming your going though the udemy blockchain course, turns out its just a problem with the postman check this out Flask app request.get_json() return (Ellipsis, Ellipsis) instead of json我假设您正在学习 udemy 区块链课程,结果证明这只是 postman 的问题,请查看Flask 应用程序 request.get_json() 返回(省略号,省略号)而不是 Z466DEEC76ECDF6324FCA6D38571

If you are using python 3.9 and getting this error then Build a virtual environment in anaconda with python 3.6 and use this python interpreter for all Spyder consoles.如果您正在使用 python 3.9 并收到此错误,请使用 python 3.6 在 anaconda 中构建一个虚拟环境,并将此 python 解释器用于所有 Spyder 控制台。 It worked in my case.它适用于我的情况。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 sanic( ) - AttributeError: 'Request' object 没有属性 'split' - sanic( ) - AttributeError: 'Request' object has no attribute 'split' /invoice/add_invoice/ 'int' 对象的 AttributeError 在使用 in_bulk 时没有属性 '_meta' - AttributeError at /invoice/add_invoice/ 'int' object has no attribute '_meta' while using in_bulk AttributeError:“ unicode”对象没有属性“ get”-在Django表单中 - AttributeError: 'unicode' object has no attribute 'get' - In Django Forms Django 查看 AttributeError: 'str' object 没有属性 'get' - Django view AttributeError: 'str' object has no attribute 'get' AttributeError: 'list' 对象没有使用 Selenium 和 Python 的属性 'click' - AttributeError: 'list' object has no attribute 'click' using Selenium and Python 如何更改发布请求以获取 postman 中的请求? - How to change post request to get request in postman? AttributeError:'NoneType'对象没有属性'is_active' - AttributeError: 'NoneType' object has no attribute 'is_active' AttributeError:'WebElement'对象没有属性'getElementById' - AttributeError: 'WebElement' object has no attribute 'getElementById' AttributeError:'str'对象没有属性'resolve' - AttributeError: 'str' object has no attribute 'resolve' AttributeError问题:'WebDriver'对象没有属性'manage' - Issue with AttributeError: 'WebDriver' object has no attribute 'manage'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM