[英]Python opening a hebrew path to file and using glob with hebrew
我在希伯來語中有一個根目錄,在希伯來語中有一個文件名。 我希望執行以下操作:
fullPath = os.path.join(dirName, fileName)
f = file(fullPath)
我也希望找到所有以希伯來語前綴開頭的Excel文件:
excelPath= os.path.join(dirName, "%s*.xlsx" % hebrewPrefix)
for fn in glob.glob(excelPath):
print fn
我該如何實現?
它按預期日本(假設我有文件夾こんにち包含文件世界的.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
您在希伯來語中應該不會遇到任何困難。 唯一的問題是,如果您的文件系統不支持UTF-8的文件名...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.