python使用xml時報錯如下:
"cannot serialize %r (type %s)" % (text, type(text).__name__)
TypeError: cannot serialize 512 (type int)
這裏的512是我報錯xml,etree.ElementTree.SubElement().text添加text內容時這裏爲數字512,這種報錯是因爲xml的text內容應該爲字符串,添加數字序列化報錯,將所有的數字改爲字符字符串形式即可
python使用xml時報錯如下:
"cannot serialize %r (type %s)" % (text, type(text).__name__)
TypeError: cannot serialize 512 (type int)
這裏的512是我報錯xml,etree.ElementTree.SubElement().text添加text內容時這裏爲數字512,這種報錯是因爲xml的text內容應該爲字符串,添加數字序列化報錯,將所有的數字改爲字符字符串形式即可
class MetaCls(type): def __new__(cls, *args, **kwargs): print("in MetaCls") # return super(Meta