運(yùn)行一下程序,出現(xiàn)SyntaxError: invalid character in identifier,求解決方法
import os,sys
class programmer(object):
? ? hobby="play computer"
? ? def __init__(self,name,age,weight):
? ? ? ? self.name=name
? ? ? ? self._age=age
? ? ? ? self.__weight=weight
? ? @classmethod
? ? def get_hobby(cls):
? ? ? ? return cls.hobby
? ? @property
? ? def get_weight(self):
? ? ? ? return self.__weight
? ? def self_introduce(self):
? ? ? ? print("My name is %s \nI am %s yeas old\n"%(self.name, self._age))
? ??
if __name__=='__main__':
? ? prog=programmer('Albert',25,80)
? ? print(dir(prog))
? ? print(programmer.get_hobby())
? ? print(prog.get_weight)
? ? print(prog._programmer__weight,prog.self_introduce)
2016-11-07
報錯原因是因為,你第19行print打印括號是中文的,改成英文的就可以。
2016-11-06
找詳細(xì)的報錯,第幾行?有沒有中文狀態(tài)下的字符
2016-11-06
找到root cause,謝謝!