用python寫一個(gè)帶有g(shù)ui界面的密碼生成器
需要用到的庫(kù):
- tkinter:構(gòu)建gui界面
- pyperclip:復(fù)制功能
- random:生成隨機(jī)數(shù)
- string:處理字符串
代碼:
from tkinter import *
import random, string
import pyperclip
root =Tk()
root.geometry("400x400")
root.resizable(0,0)
root.title("密碼生成器")
heading = Label(root, text = '密碼' , font ='arial 15 bold').pack()
pass_label = Label(root, text = '密碼長(zhǎng)度', font = 'arial 10 bold').pack()
pass_len = IntVar()
length = Spinbox(root, from_ = 8, to_ = 32 , textvariable = pass_len , width = 15).pack()
pass_str = StringVar()
def Generator():
password = ''
for x in range (0,4):
password = random.choice(string.ascii_uppercase)+random.choice(string.ascii_lowercase)+random.choice(string.digits)+random.choice(string.punctuation)
for y in range(pass_len.get()- 4):
password = password+random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits + string.punctuation)
pass_str.set(password)
Button(root, text = "獲取密碼" , command = Generator ).pack(pady= 5)
Entry(root , textvariable = pass_str).pack()
def Copy_password():
pyperclip.copy(pass_str.get())
Button(root, text = '復(fù)制密碼', command = Copy_password).pack(pady=5)
root.mainloop()
運(yùn)行效果:

想要了解更多關(guān)于python的知識(shí),資訊,實(shí)用工具歡迎關(guān)注python客棧
以上就是用python寫一個(gè)帶有g(shù)ui界面的密碼生成器的詳細(xì)內(nèi)容,更多關(guān)于python gui密碼生成器的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
- 基于python2.7實(shí)現(xiàn)圖形密碼生成器的實(shí)例代碼
- python如何隨機(jī)生成高強(qiáng)度密碼
- python隨機(jī)生成大小寫字母數(shù)字混合密碼(僅20行代碼)
- Python實(shí)現(xiàn)生成密碼字典的方法示例
- python利用itertools生成密碼字典并多線程撞庫(kù)破解rar密碼
- python 隨機(jī)生成10位數(shù)密碼的實(shí)現(xiàn)代碼
- python 腳本生成隨機(jī) 字母 + 數(shù)字密碼功能
- Python生成隨機(jī)密碼的方法
- Python簡(jiǎn)單生成8位隨機(jī)密碼的方法
- Python編程生成隨機(jī)用戶名及密碼的方法示例
相關(guān)文章
詳解Python如何獲取視頻文件的大小和時(shí)長(zhǎng)
這篇文章主要為大家詳細(xì)介紹了Python如何實(shí)現(xiàn)獲取視頻文件的大小和時(shí)長(zhǎng),文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起了解一下2023-03-03
淺談python 四種數(shù)值類型(int,long,float,complex)
下面小編就為大家?guī)?lái)一篇淺談python 四種數(shù)值類型(int,long,float,complex)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2016-06-06
python圖片剪裁代碼(圖片按四個(gè)點(diǎn)坐標(biāo)剪裁)
這篇文章主要介紹了python圖片剪裁代碼(圖片按四個(gè)點(diǎn)坐標(biāo)剪裁),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-03-03
使用Python批量刪除MySQL數(shù)據(jù)庫(kù)的全部外鍵
這篇文章主要為大家詳細(xì)介紹了如何使用Python批量刪除MySQL數(shù)據(jù)庫(kù)的全部外鍵,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2024-04-04
Python configparser模塊操作代碼實(shí)例
這篇文章主要介紹了Python configparser模塊操作代碼實(shí)例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-06-06


