Skip to content

SVG填充

SVG填充为白色

python
import re
import sys


def modify_svg_file(svg_file):
    with open(svg_file, 'r') as f:
        svg_content = f.read()

    modified_content = re.sub(r'<path', r'<path fill="#fff"', svg_content)

    with open(svg_file, 'w') as f:
        f.write(modified_content)

    print('write to', svg_file)

svg_file = sys.argv[1]
print('open', svg_file)
modify_svg_file(svg_file)

Released under the MIT License.