Skip to content Skip to sidebar Skip to footer

Opening A File With An Accented Character In Its Name, In Python 2 On Windows

In a directory in Windows I have 2 files, both of them with an accented character in its name: t1û.fn and t2ű.fn; The dir command in the Command Prompt shows both correctly: S:\p

Solution 1:

Use a unicode string:

f1 = open(u"t1\u00fb.fn")     # t1û.fn
f2 = open(u"t2\u0171.fn")     # t2ű.fn

Post a Comment for "Opening A File With An Accented Character In Its Name, In Python 2 On Windows"