os.walk() strips polish characters

后端 未结 1 1097
野性不改
野性不改 2020-12-11 06:12

So what I\'m trying to do is fix some id3tags of mp3 files. It all works, except for files with any kind of accent, because os.walk seems to strip them.

For example,

相关标签:
1条回答
  • 2020-12-11 06:40

    Did you define folder as a Unicode string? This has implications on how os.walk() matches its subdirectories, or better, the type of string that it returns.

    >>> for a,b,c in os.walk("."):
    ...  print b
    ...  break
    ...
    ['DLLs', 'Doc', 'include', 'Lib', 'libs', 'tcl', 'Tools']
    >>> for a,b,c in os.walk(u"."):
    ...  print b
    ...  break
    ...
    [u'DLLs', u'Doc', u'include', u'Lib', u'libs', u'tcl', u'Tools']
    
    0 讨论(0)
提交回复
热议问题