質問

I'm trying to make my app run files with Unicode characters, but for this, you must decode before them. For this I am using ConfigObj.py. But when I run the app, get the following error:

Traceback (most recent call last):
   File "GCW_Player.py", line 757, in <module>
     epMEDIA ()
   File "GCW_Player.py", line 89, in __ init__
     self.keyhandler (event.key)
   File "GCW_Player.py", line 133, in keyhandler
     if key == K_RIGHT: self.k_goto ()
   File "GCW_Player.py", line 211, in k_goto
     self.go_to ()
   File "GCW_Player.py", line 649, in go_to
     self.list.generate (self.sec_ftypes)
   File "/data/epm_core.py", line 114, in generate
     inp = os.listdir (self.path)
TypeError: coercing to Unicode: need string or buffer, tuple found

Below, let the corresponding part file in the app:

    def generate(self, filetypes):
        self.data = []
        inp = os.listdir(self.path)
        inp.sort()
        for line in inp:
            file = File(os.path.join(self.path, line), filetypes)
            if file.type != None:
                self.data.append(file)

Can anyone help me? I do not know what to do in this case. I've never experienced this situation. Thank you.

役に立ちましたか?

解決

Your self.path contains multiple paths, maybe you need:

def generate(self, filetypes):
    self.data = []

    for folder in self.path:
        inp = os.listdir(folder)
        inp.sort()
        for line in inp:
            file = File(os.path.join(folder, line), filetypes)
            if file.type != None:
                self.data.append(file)

他のヒント

Ok, just a long time I've solved this issue, with simple modifying. Just I use u"" string in all parts that can have a unicode caracter. Using encode.utf8().decode.utf8() is more difficult, so just use u"" strings in the correct moments.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top