Python SVG parser

前端 未结 3 2043
北恋
北恋 2020-12-14 08:32

I want to parse an SVG file using python to extract coordinates/paths (I believe this is listed under the \"path\" ID, specifically the d=\"...\"/>). This data will eventua

3条回答
  •  一个人的身影
    2020-12-14 09:01

    Ignoring transforms, you can extract the path strings from an SVG like so:

    from xml.dom import minidom
    
    doc = minidom.parse(svg_file)  # parseString also exists
    path_strings = [path.getAttribute('d') for path
                    in doc.getElementsByTagName('path')]
    doc.unlink()
    

提交回复
热议问题