用python寫乙個帶有gui介面的密碼生成器

2022-10-03 18:33:13 字數 1260 閱讀 5194

需要用pspuf到的庫:

**: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 = '密碼長度', font = 'arial 10 bold').pack()

pass_len = intvar()

length = spinbox(root, from_ = 8, to_ = 32 , textvariable = pass_len , width = 15).pack()

paswww.cppcns.coms_str = strin**ar()

def generator():

password = ''

for x in range (0,4):

password = random.choice(string.ascii_uppercase)+random.choice(string.ascii_lowercase)+random.choice(st程式設計客棧ring.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(pad程式設計客棧y= 5)

entry(root , textvariable = pass_str).pack()

def copy_password():

pyperclip.copy(pass_str.get())

button(root, = '複製密碼', command = copy_password).pack(pady=5)

root.mainloop()

執行效果:

用python寫乙個restful API

coding utf 8 package.module python實現的圖書的乙個restful api.restful api 一般模式 get select 從伺服器取出資源 一項或多項 post create 在伺服器新建乙個資源。put update 在伺服器更新資源 客戶端提供改變後的完...

python寫乙個服務 Python寫乙個服務

coding utf 8 import json from urllib.parse import parse qs from wsgiref.server import make server 定義函式,引數是函式的兩個引數,都是python本身定義的,預設就行了。定義檔案請求的型別和當前請求成功...

用python寫乙個蛇形矩陣

蛇形矩陣,如 10 11 12 1 9 16 13 2 8 15 14 3 7 6 5 4從右上角大回環,其實挺簡單,思路想明白了就順了。這樣的矩陣可以看做二維陣列,python對陣列的寫法很麻煩,用numpy生成就簡單多了 myarray np.zeros n,n dtype np.int16 有...