系統提示工具
這個工具用到了win10toast函式庫來觸發系統的通知,可以用來提示重要事情。
#定时通知脚本 from win10toast import ToastNotifier import time #构建通知对象实例 toaster = ToastNotifier() title = input("请输入事件标题:") content = input("请输入事件提要") time_min = float(input("请输入提醒时间(分钟):")) #time_min = time_min * 60 print("设置完成!") time.sleep(1) print("开始运行..") time.sleep(time_min) toaster.show_toast(f"{title}", f"{content}", duration=10, threaded=True) while toaster.notification_active(): time.sleep(0.005)
資料夾清理工具
import os import threading import time def get_file_list(file_path): #文件按最后修改时间排序 dir_list = os.listdir(file_path) if not dir_list: return else: dir_list = sorted(dir_list, key=lambda x: os.path.getmtime(os.path.join(file_path, x))) return dir_list def get_size(file_path): """[summary] Args: file_path ([type]): [目录] Returns: [type]: 返回目录大小,MB """ totalsize=0 for filename in os.listdir(file_path): totalsize=totalsize+os.path.getsize(os.path.join(file_path, filename)) #print(totalsize / 1024 / 1024) return totalsize / 1024 / 1024 def detect_file_size(file_path, size_Max, size_Del): """[summary] Args: file_path ([type]): [文件目录] size_Max ([type]): [文件夹最大大小] size_Del ([type]): [超过size_Max时要删除的大小] """ print(get_size(file_path)) if get_size(file_path) > size_Max: fileList = get_file_list(file_path) for i in range(len(fileList)): if get_size(file_path) > (size_Max - size_Del): print ("del :%d %s" % (i + 1, fileList[i])) #os.remove(file_path + fileList[i]) def detectFileSize(): #检测线程,每个5秒检测一次 while True: print('======detect============') detect_file_size("/Users/aaron/Downloads/", 100, 30) time.sleep(5) if __name__ == "__main__": #创建检测线程 detect_thread = threading.Thread(target = detectFileSize) detect_thread.start()
PDF檔案轉音訊
import pyttsx3 import pyPDF2 book = open('路径/book.pdf',rb) pdfreader = pyPDF2.PdfFileReader(book) pages = pdfreader.numPages print(pages) voice = pyttsx3.init() page = pdfreader.getpage(3) text = page.extractText() speaker.say(text) speaker.runAndWait()
批次壓縮檔案
import zipfile # zipfile库 压缩文件 import os import time def batch_zip(start_dir): start_dir = start_dir #文件路径 file_news = start_dir + '.zip' # 压缩后文件夹的名字 z = zipfile.ZipFile(file_news, 'w', zipfile.ZIP_DEFLATED) for dir_path, dir_names, file_names in os.walk(start_dir): #避免从根目录复制 f_path = dir_path.replace(start_dir, '') #压缩所有文件 f_path = f_path and f_path + os.sep for filename in file_names: z.write(os.path.join(dir_path, filename), f_path + filename) z.close() return file_news batch_zip('./data/ziptest')
郵件發送
# 1、导入模块 import yagmail # 2、设置smtp服务信息 yag = yagmail.SMTP(user="改成自己的邮箱账号@126.com", password="改成自己的邮箱密码", host='smtp.126.com') # 3、设置邮件主题与邮件内容 subject = 'Python邮件测试' content = ['Python邮件测试 -- 邮件来自黑马程序员Python+大数据'] # 4、发送邮件 yag.send('gocndws@126.com', subject, content)
以上是實用的Python腳本有哪些的詳細內容。更多資訊請關注PHP中文網其他相關文章!

Python在自動化、腳本編寫和任務管理中表現出色。 1)自動化:通過標準庫如os、shutil實現文件備份。 2)腳本編寫:使用psutil庫監控系統資源。 3)任務管理:利用schedule庫調度任務。 Python的易用性和豐富庫支持使其在這些領域中成為首選工具。

要在有限的時間內最大化學習Python的效率,可以使用Python的datetime、time和schedule模塊。 1.datetime模塊用於記錄和規劃學習時間。 2.time模塊幫助設置學習和休息時間。 3.schedule模塊自動化安排每週學習任務。

Python在遊戲和GUI開發中表現出色。 1)遊戲開發使用Pygame,提供繪圖、音頻等功能,適合創建2D遊戲。 2)GUI開發可選擇Tkinter或PyQt,Tkinter簡單易用,PyQt功能豐富,適合專業開發。

Python适合数据科学、Web开发和自动化任务,而C 适用于系统编程、游戏开发和嵌入式系统。Python以简洁和强大的生态系统著称,C 则以高性能和底层控制能力闻名。

2小時內可以學會Python的基本編程概念和技能。 1.學習變量和數據類型,2.掌握控制流(條件語句和循環),3.理解函數的定義和使用,4.通過簡單示例和代碼片段快速上手Python編程。

Python在web開發、數據科學、機器學習、自動化和腳本編寫等領域有廣泛應用。 1)在web開發中,Django和Flask框架簡化了開發過程。 2)數據科學和機器學習領域,NumPy、Pandas、Scikit-learn和TensorFlow庫提供了強大支持。 3)自動化和腳本編寫方面,Python適用於自動化測試和系統管理等任務。

兩小時內可以學到Python的基礎知識。 1.學習變量和數據類型,2.掌握控制結構如if語句和循環,3.了解函數的定義和使用。這些將幫助你開始編寫簡單的Python程序。

如何在10小時內教計算機小白編程基礎?如果你只有10個小時來教計算機小白一些編程知識,你會選擇教些什麼�...


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

WebStorm Mac版
好用的JavaScript開發工具

MinGW - Minimalist GNU for Windows
這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器