在django 1.8上的python3.5中打印变量类型

时间:2016-01-05 03:59:58

标签: django python-3.5

我很难确定变量的类型,因为我在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的runserver上返回输出。

1 个答案:

答案 0 :(得分:24)

Python 3中的

$set: { 'mailingList.$.email': 'newmail@gmail.com' } 不再是一个语句,而是一个函数。您需要使用括号来调用它:

print