我输入
config = {}
config['x'] = ["vision","unknown","SCH-i569","harmony","中国移动"]
没问题。 python控制台可以处理它
但是当我在类init函数中编写相同的代码时,会出现一些编码问题
class Profile(object):
def __init__(self):
attributes = []
attributes.append('8')
attributes.append('htc')
config = {}
config['x'] = ["vision","unknown","SCH-i569","harmony","中国移动"]
print config['x']
attributes.append(config['x'])
self.attributes = attributes
def getAttributes(self):
return self.attributes
它出现问题:
File "<stdin>", line 7
SyntaxError: (unicode error) 'utf8' codec can't decode byte 0xd6 in position 0: invalid continuation byte
当我删除"中国移动"
时,班级工作。我不知道为什么一个类和其他