【发布时间】:2010-10-04 13:51:36
【问题描述】:
我正在编写一个必须移动一些文件的脚本,但不幸的是,os.path 似乎不太适合国际化。当我有以希伯来语命名的文件时,就会出现问题。这是目录内容的屏幕截图:
(来源:thegreenplace.net)
现在考虑遍历此目录中文件的这段代码:
files = os.listdir('test_source')
for f in files:
pf = os.path.join('test_source', f)
print pf, os.path.exists(pf)
输出是:
test_source\ex True
test_source\joe True
test_source\mie.txt True
test_source\__()'''.txt True
test_source\????.txt False
注意os.path.exists 是如何认为希伯来文命名的文件甚至不存在的?
我该如何解决这个问题?
Windows XP Home SP2 上的 ActivePython 2.5.2
【问题讨论】:
标签: python internationalization hebrew