【发布时间】:2012-08-19 15:12:32
【问题描述】:
代码:
class MyClass:
def __init__(self, aa ):
print('aa='+str(aa)+' of type '+str(type(aa)))
self.aa = aa,
print('self.aa='+str(self.aa)+' of type '+str(type(self.aa)))
DEBUG = MyClass(aa = 'DEBUG')
输出:
aa=DEBUG of type <type 'str'>
self.aa=('DEBUG',) of type <type 'tuple'>
为什么self.aa 变成元组而不是字符串?
【问题讨论】: