ValueError: need more than 1 value to unpack

class Person():


    def __init__(self, Newname, Newage, Newtype):
        self.type = Newtype,self.name = Newname,self.age = Newage,  

这种写法是错误的,不能写在同一行!


#     def __init__(self, Newname,Newage,Newtype):
#         self.name = Newname, 
#         self.age = Newage,

#         self.type = Newtype,



from django.http import  HttpResponse
from django.template import Template ,Context
import datetime
from HelloDjango.Model.Person import *




def Hello(request , offset ):
    
    tempStr = "{{person.name}} {{person.age}} {{person.type}}"
    tempAnswer = {"person" : Person("hjc", "11", "man")}
#     
#     tempStr = "{{person.name}} {{person.age}} {{person.type}}"
#     tempAnswer = {"person" : Person('hjc' , '11' ,'man')}
    
    t = Template(tempStr)
    c = Context(tempAnswer)
    return HttpResponse(t.render(c))



你可能感兴趣的:(Python)