aben20807 / blog-post-issues

https://aben20807.github.io/
MIT License
9 stars 2 forks source link

ConfigParser: use newline in INI file not working #133

Open aben20807 opened 2 years ago

aben20807 commented 2 years ago

The issue is caused by the '#' symbol which is the comment of ini file

[Settings]
tags = -
    #photography #photographylovers #photoshoot #outdoors #nature #micro_lens #mushroom #菇 #成大 #榕園 #ncku

The solution is to change the comment symbol to ';' of the configparser:

config = configparser.ConfigParser(
  comment_prefixes=";"
)  # the tags startswith # may be see as comment
config.read(get_config_path(), encoding="utf-8-sig")

Demo: https://github.com/aben20807/ezexif/blob/107015ef5037d8022c451ed5a5d2b3e963733267/ezexif/ezexif.py#L100-L102