ConfigParser: use newline in INI file

Tim Chase python.list at tim.thechases.com
Thu Mar 7 11:46:19 EST 2019


On 2019-03-07 17:19, tony wrote:
> Python 3.5.3 (default, Sep 27 2018, 17:25:39)
> >>> "a\\nb".decode("string-escape")  
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> AttributeError: 'str' object has no attribute 'decode'

Looks like bytestring.decode('unicode_escape') does what you're
describing:

  >>> b"hello\nworld".decode('unicode_escape')
  'hello\nworld'
  >>> print(b"hello\nworld".decode('unicode_escape'))
  hello
  world

-tkc





More information about the Python-list mailing list