简体   繁体   English

Python打开文件的希伯来语路径,并在希伯来语中使用glob

[英]Python opening a hebrew path to file and using glob with hebrew

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: 我也希望找到所有以希伯来语前缀开头的Excel文件:

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

How can I achieve that? 我该如何实现?

It works as expected on Japanese (assuming I have the folder こんにちは containing the file 世界.xls ): 它按预期日本(假设我有文件夹こんにち包含文件世界的.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... 唯一的问题是,如果您的文件系统不支持UTF-8的文件名...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM