[英]'list' object has no attribute 'get'
我想在 views.py 中返回數字,但總是得到屬性錯誤。 我不想得到什么,我只想返回一個變量,但它總是顯示“object 沒有屬性‘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 中的代碼 function
number = 3
return number
誰能幫我解決這個問題。 我在網上搜索過,但沒有找到解決方案!
視圖需要返回一個 HttpResponse。
from django.http import HttpResponse
def my_view(request):
return HttpResponse('hello')
您還應該分享您的整個觀點,而不僅僅是其中的兩行。
您是否嘗試過 print(type()) 以檢查變量是否確實是您想要的類型?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.