开发者社区> 问答> 正文

AttributeError:“元组”对象没有属性“ status_code”

我是python的初学者。我不明白问题是什么?

the runtime process for the instance running on port 43421 has unexpectedly quit

ERROR    2019-12-24 17:29:10,258 base.py:209] Internal Server Error: /input/
Traceback (most recent call last):
  File "/var/www/html/sym_math/google_appengine/lib/django-1.3/django/core/handlers/base.py", line 178, in get_response
    response = middleware_method(request, response)
  File "/var/www/html/sym_math/google_appengine/lib/django-1.3/django/middleware/common.py", line 94, in process_response
    if response.status_code == 404:
AttributeError: 'tuple' object has no attribute 'status_code'

展开
收起
几许相思几点泪 2019-12-25 23:00:06 1807 0
1 条回答
写回答
取消 提交回答
  • 我将尝试通过一个简单的示例来说明此错误是如何产生的

    def example_error():
        a1 = "I am here"
        b1 = "you are there"
        c1 = "This is error"
        return a1, b1, c1
    
    def call_function():
        strings = example_error()
        s1 = strings.a1
        s2 = strings.b1
        s3 = strings.c1
        print(s1, s2, s3)
    
    call_function()
    
    

    这将返回错误

    AttributeError: 'tuple' object has no attribute 'a1'
    
    

    因为我在example_error函数中返回了三个变量a1,b1,c1,并尝试使用单个变量字符串来获取它们。

    我可以使用以下修改后的call_function摆脱它

    def call_function():
        strings = example_error()
        s1 = strings[0]
        s2 = strings[1]
        s3 = strings[2]
        print(s1, s2, s3)
    call_function()
    由于您没有显示代码,因此我假
    设```  
    您已经完成了与第一种情况类似的操作。
    2019-12-25 23:00:51
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载