python script Non-ASCII character
MRAB
python at mrabarnett.plus.com
Sun Mar 19 23:36:45 EDT 2017
More information about the Python-list mailing list
Sun Mar 19 23:36:45 EDT 2017
- Previous message (by thread): python script Non-ASCII character
- Next message (by thread): how to corss-compile azure-iot-sdk-python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2017-03-20 02:50, eryk sun wrote: > On Sun, Mar 19, 2017 at 11:06 PM, MRAB <python at mrabarnett.plus.com> wrote: >> >> If you're using Unicode string literals, your choices are: >> >> 1. Raw string literals: >> >> var1 = ur"C:\Users\username\Desktop\η γλωσσα μου\mylanguage\myfile" > > Raw unicode literals are practically useless in Python 2. They're not > actually raw because \u and \U are still parsed as Unicode escapes, > e.g. ur"C:\Users" and ur"C:\users" are syntax errors. > Thanks for the correction. I haven't used Python 2 for a long time (apart from running the unit tests when I make a new release of the regex module)! >> 2. Slashes: >> >> var1 = u"C:/Users/username/Desktop/η γλωσσα μου/mylanguage/myfile" > > I prefer to normalize a path with os.path.normpath, or pathlib.Path in > Python 3. This converts slashes to backslashes to get a canonical > Windows path. IMO, it's also visually better in a text representation > or error messages. Otherwise at runtime joined paths often end up with > mixed slashes, which to me is ugly. >
- Previous message (by thread): python script Non-ASCII character
- Next message (by thread): how to corss-compile azure-iot-sdk-python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list