Frage

I have a root dir in hebrew and a file name in hebrew. I wish to do the following:

fullPath = os.path.join(dirName, fileName)
f = file(fullPath)

and also I wish to find all the excel files that starts with a hebrew prefix:

excelPath= os.path.join(dirName, "%s*.xlsx" % hebrewPrefix)
for fn in glob.glob(excelPath):
            print fn

How can I achieve that?

War es hilfreich?

Lösung

It works as expected on Japanese (assuming I have the folder こんにちは containing the file 世界.xls):

Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> fullpath = os.path.join("こんにちは","世界.*")
>>> import glob
>>> for fn in glob.glob(fullpath):
...     print fn
... 
こんにちは/世界.xls

You shouldn't have any difficulties in Hebrew. The only problem would be if your filesystem does not support UTF-8 for file names...

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top