我很难确定变量的类型,因为我在 python2 上使用过并且刚刚迁移到 python3
from django.http import HttpResponse
def myview(request):
x = "Name"
print (x)
print type(x)
return HttpResponse("Example output")
由于打印类型(x),此代码将引发错误。但是,如果您将该语法行更改为 type(x)。该类型不会在 django 的运行服务器上返回输出。
最佳答案
print
在 Python 3 中不再是语句,而是函数。您需要使用括号调用它:
print(type(x))
关于django - 在 Django 1.8 上的 python3.5 中打印变量类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34603937/