如何在 python spyne 中使用 a:b 之类的属性名称?
how to use attribute names like a:b in python spyne?
我正在尝试更改属性名称,我拥有的是
class table(ComplexModel):
diffgr=XmlAttribute(String)
rowOrder=XmlAttribute(String)
我可以将 diffgr
更改为 diffgr:id
吗?
因为我所指的方案有
<Table diffgr:id="Table1" msdata:rowOrder="0">
我真的卡住了,有什么帮助吗?
您所要求的完全不可能,因为它是无效的 Python 语法。
看看rules for giving names in Python:
- 变量名只能包括a-z、A-Z、_和0-9
- 但它们可能仅以 a-z、A-Z、_
开头
找到解决方案,
在
diffgr:id
diffgr 是一个命名空间
因此为了定义一个子命名空间,考虑到我的例子,
应该是
id =XmlAttribute(String(sub_ns='diffgr'))
我正在尝试更改属性名称,我拥有的是
class table(ComplexModel):
diffgr=XmlAttribute(String)
rowOrder=XmlAttribute(String)
我可以将 diffgr
更改为 diffgr:id
吗?
因为我所指的方案有
<Table diffgr:id="Table1" msdata:rowOrder="0">
我真的卡住了,有什么帮助吗?
您所要求的完全不可能,因为它是无效的 Python 语法。
看看rules for giving names in Python:
- 变量名只能包括a-z、A-Z、_和0-9
- 但它们可能仅以 a-z、A-Z、_ 开头
找到解决方案, 在
diffgr:id
diffgr 是一个命名空间
因此为了定义一个子命名空间,考虑到我的例子, 应该是
id =XmlAttribute(String(sub_ns='diffgr'))