我有一个关键字参数函数:
def f1(**kw):
for key,val in kw.iteritems():
print "key=%s val=%s" % (key,val)
f1(Attr1 = "Val1", Attr2 = "Val2") # works fine.
f1(Attr1-SubAttr = "Val1", Attr2 = "Val2") # complains about keyword being an expression.
f1("Attr1-SubAttr" = "Val1", Attr2 = "Val2") # doesn't work either.
如何传递带连字符的关键字?由于我正在解析现有的遗留数据库,因此我无法控制这些关键字。