从这里改编的代码:
#from 'foo_bar' to 'Foo.Bar'
def lower_case_underscore_to_camel_case(self, string):
print string
class_ = string.__class__
return class_.join('.', map(class_.capitalize, string.split('_')))
输出:
client_area
TypeError: descriptor 'join' requires a 'unicode' object but received a 'str'
特别令人失望,因为源代码指出:
"""将字符串或unicode从小写下划线转换为驼峰式"""
如何解决这个问题?
轻松修复:
return str.join('.', map(class_.capitalize, string.split('_')))
谁能解释一下整个过程?