我如何解决此错误“ TypeError:无法连接'str'和'instance'对象”

时间:2019-04-06 20:00:57

标签: python python-2.7

我是编程和python本身的新手。我陷入下面提到的代码中 我本人尝试对其进行故障排除,但没有成功。

class Student:
    def __init__(self,name,contact):
        self.name = name
        self.contact = contact

    def getdata(self):
        print ("Accepting Data")
        self.name = input("Enter the name of student: ")
        self.contact = input("Enter contact number: ")

    def putdata(self):
        print ('The name is:' +self.name,'Contact number of student you entered is:' +self.contact)



John = Student("blank",0)
John.getdata()
John.putdata()

1 个答案:

答案 0 :(得分:0)

我切换到python3并得到解决