Python版本:2.7.3
文件名:测试雪人字符--☃--.mp3
运行了以下测试,但都没有成功。
>>> os.path.exist('test snowman character --☃--.mp3')
False
>>> os.path.exist(repr('test snowman character --☃--.mp3'))
False
>>> os.path.isfile('test snowman character --\\xe2\\x98\\x83--.mp3')
False
>>> os.path.isfile(r'test snowman character --\\xe2\\x98\\x83--.mp3')
False
>>> os.path.isfile('test snowman character --☃--.mp3'.decode('utf-8'))
False
尝试使用glob检索文件,即使测试也失败了。
目标是检测并将此文件复制到另一个文件夹中,请提供建议。
os.listdir(u'.')
告诉你当前目录中有什么? - Martijn Pieters