我曾经OS.步行()很慢,然后我试着斯堪的纳维亚步行街(),速度与windows search相同。 我发现有一个名为faster\u than\u walk的包,但我无法安装该包,因为它显示以下错误。你知道吗
ERROR: Command errored out with exit status 1: command: 'c:\users\regiment\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\Regiment\AppData\Local\Temp\pip-install-e640spf_\faster-than -walk\setup.py'"'"'; file='"'"'C:\Users\Regiment\AppData\Local\Temp\pip-install-e640spf_\faster-than-walk\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\Regiment\AppData\Local\Temp\pip-record-sndrd71q\install-record.txt' --single-version-externally-managed --compile cwd: C:\Users\Regiment\AppData\Local\Temp\pip-install-e640spf_\faster-than-walk\
这是我现在用来搜索文件的代码。你知道吗
import fnmatch
import os
import shutil
import getpass
import scandir
usern = getpass.getuser()
rootPath = input('Please enter the location: ')
pattern = input('Please enter resto ID: ')
pattern = pattern + "_*"
for root, dirs, files in scandir.walk(rootPath):
for filename in fnmatch.filter(files, pattern):
print(os.path.join(root, filename))
newPath = shutil.copy(os.path.join(root, filename), 'C:\\Users\\'+ usern +'\\Desktop\\fetchy')
print('Done')
请帮助我提高搜索速度。Python应该在所有子文件夹中搜索一个文件。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐