0

I am trying to select files and folders using filedialog.askopenfilenames in spyder. My python is 2.7.12.

My code:

import tkFileDialog as filedialog files = filedialog.askopenfilenames(initialdir = "/media/note/Results", title = "Select zipped files", filetypes = [('Zip files', '.zip')])

And it returns:

(u'/media/note/Results/CTR1.zip', u'/media/note/Results/CTR2.zip')

What is this 'u' at the beginning? Can I get rid of it?

Thank you!

rfc
  • 1

1 Answers1

0

The prefixed u specifies that the string is unicode. To convert it to a string object I had success with:

u = u"\u2115 \u2286 \u2115\u2080 \u2282 \u2124 \u2282 \u211a \u2282 \u211d \u2282 \u2102, \u22a5 < a \u2260 b \u2261 c \u2264 d \u226a \u22a4 \u21d2 (A \u21d4 B)\n"
s = u.encode("utf-8")
print type(u),u
print type(s),s

Basically, a unicode type is a multibyte encoding while str is single byte per character encoding.

nabin-info
  • 289
  • 1
  • 7