有时调试内容的最佳方法是在页面上打印一些东西exit(),我怎样才能在Python/Django站点中执行此操作?
例如在PHP中:
echo $var;
exit();
Run Code Online (Sandbox Code Playgroud)
谢谢
int*_*jay 16
把它放在你的视图功能中:
from django.http import HttpResponse
return HttpResponse(str(var))
Run Code Online (Sandbox Code Playgroud)
小智 14
我只是想给出一个替代答案:只需使用print语句并为您的django站点提供服务python manage.py runserver
在这种情况下,print语句会显示在您的shell中,并且您的站点将继续正常运行.