Python list to XML and vice versa

后端 未结 2 927
长发绾君心
长发绾君心 2021-01-19 21:51

I have some python code that I wrote to convert a python list into an XML element. It\'s meant for interacting with LabVIEW, hence the weird XML array format. Anyways, here\

2条回答
  •  广开言路
    2021-01-19 22:39

    start inside out:

    def group(seq, k):
        return [seq[i:i+k] for i in range(0, len(seq), k)]
    
    unflattened = group(group(data, 2), 2)
    

    Your example might be easier, if your dimensions were not all the same. But I think the above code should work.

提交回复
热议问题