我使用dicttoxml模块将字典转换为xml。在
代码:
cfg_dict = { 'mobile' :
{ 'checkBox_OS' :
{ 'status' : 'None',
'radioButton_Andriod' :
{ 'status' : 'None',
'comboBox_Andriod_Brands' : 'LG'},
'radioButton_Windows' :
{ 'status' : 'None',
'comboBox_Windows_Brands' : 'Nokia'},
'radioButton_Others' :
{ 'status' : 'None',
'comboBox_Others_Brands' : 'Apple'}},
'checkBox_Screen_size' :
{ 'status' : 'None',
'doubleSpinBox_Screen_size' : '5.0' }}
}
from dicttoxml import dicttoxml
xml = dicttoxml(self.cfg_dict)
print (xml)
输出:
^{pr2}$我不知道它为什么用b'括起来。如何在没有这个b“”的情况下生成xml字符串?在
浏览器在打开包含此内容的xml文件时也会发出错误消息。在
这是python3中非Unicode字符串的正常表示。在Python shell中尝试以下操作:
所以一切都好。你没问题。在
另请参见^{} 与^{} 。在
编辑:
看看编码和解码是如何工作的。在
^{pr2}$所以只要使用}可能是{}。在
my_byte_string.decode(my_encoding)
,其中{这里是图书馆的作者。在
看起来您使用的是python3。Python3以二进制格式存储字符串,除非指定编码。在
{{1>将字符串{1>转换为cd2>字符串的示例:
干杯!在
相关问题 更多 >
编程相关推荐