【发布时间】:2022-12-15 05:06:31
【问题描述】:
我想在 views.py 中返回数字,但总是得到属性错误。我不想得到什么,我只想返回一个变量,但它总是显示“对象没有属性‘get’”。我曾尝试将返回数字更改为字符串和列表,但都出现此错误
Traceback (most recent call last):
File "C:\Users\Asus\AppData\Local\Programs\Python\Python310\lib\site-packages\django\core\handlers\exception.py", line 55, in inner
response = get_response(request)
File "C:\Users\Asus\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\deprecation.py", line 136, in __call__
response = self.process_response(request, response)
File "C:\Users\Asus\AppData\Local\Programs\Python\Python310\lib\site-packages\django\middleware\clickjacking.py", line 27, in process_response
if response.get("X-Frame-Options") is not None:
Exception Type: AttributeError at /scan-port/
Exception Value: 'int' object has no attribute 'get'
这是我在 views.py 函数中的代码
number = 3
return number
谁能帮我解决这个问题。我在网上搜索过,但没有找到解决方案!
【问题讨论】:
-
非常明确,
list没有属性get/method您应该尝试使用type(response)打印类型
标签: python django attributes return attributeerror