python,需要实现copy一个文件到指定目录,并设为隐藏文件
1个回答
展开全部
import platform, locale, os, time, shutil
def hideFile(filePath):
if 'Windows' in platform.system():
cmd = 'attrib +h "' + filePath +'"'
cmd = cmd.encode(locale.getdefaultlocale()[1])
os.popen(cmd).close()
time.sleep(1)
def copyFile(fromPath, toPath):
f = open(fromPath, 'rb')
t = open(toPath, 'wb+')
shutil.copyfileobj(fsrc=f, fdst=t, length=1024 * 16)
f.close()
t.close()
hideFile(toPath)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询