小工具1.1
就是把没发的代码发上去。。。
代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 | import tkinter as tk import os from time import sleep import tkinter.ttk as ttk from tkinter.filedialog import askdirectory import webbrowser from threading import Thread import sys from tkwebview2.tkwebview2 import WebView2 import time from random import randint, choice import tkinter.messagebox as msgbox from datetime import datetime from datetime import date from datetime import timedelta import random from tkinter import messagebox def locate_pip(name = ''): os.system( "where pip" ) os.system( "where pip3" ) print ( '==================================================' ) def install(name,arg1 = ' ',arg2=' '): os.system(pip_path + " install " + name + ' -i https://pypi.douban.com/simple' ) print ( '==================================================' ) def uninstall(name): if name = = 'pip' : print ( '想什么呢?你准备卸载PyPI?' ) else : os.system(pip_path + " uninstall " + name) print ( '==================================================' ) def upgrade(name = ''): os.system(python_path + " -m pip install --upgrade pip -i https://pypi.douban.com/simple" ) print ( '==================================================' ) def list_pkg(name = ''): os.system(pip_path + " list" ) print ( '==================================================' ) def about(name = ''): os.system(pip_path + " --version" ) print ( '==================================================' ) def start(func,p = ''): #print(func) dprint( '将向函数传入此类型的参数:' + str ( type (p))) dprint( '将向函数传入参数:' + p) #t=Thread(target=func,args=p) t = Thread(target = lambda :func(p)) t.start() def view(url): webbrowser. open (url) def showDebug(show_info = False ): global sdo,sdo_btn,sdi,egg_count if show_info: if sdi: sdi = False sdi_btn[ 'text' ] = '显示调试信息' else : sdi = True sdi_btn[ 'text' ] = '隐藏调试信息' else : if sdo: win.geometry( '300x340' ) sdo_btn[ 'text' ] = '显示调试选项 v' egg_count = 0 sdo = False else : win.geometry( '300x425' ) sdo_btn[ 'text' ] = '隐藏调试选项 ^' sdo = True def dprint(msg): global sdi if sdi: print (msg) def init(): global py_path,pip_path,python_path try : dprint( '正在读取配置信息' ) py_path_f = open ( "./py_path.cfg" , 'r' ,encoding = 'utf-8' ) py_path = py_path_f.read() dprint( '根据配置信息,您的Python位于:' + py_path) py_path_f.close() pip_path = py_path + "/scripts/pip.exe" python_path = py_path + "/python.exe" dprint( '读取完成' ) if py_path = = '使用环境变量' : dprint( '使用环境变量' ) pip_path = 'pip' except Exception as e: dprint( '读取设置失败:' + str (e)) py_path = askdirectory(title = '请选择Python安装路径' ) py_path_f = open ( "./py_path.cfg" , 'w' ,encoding = 'utf-8' ) py_path_f.write(py_path) py_path_f.close() pip_path = py_path + "/scripts/pip.exe" def showDebug(show_info = False ): global sdo,sdo_btn,sdi,egg_count if show_info: if sdi: sdi = False sdi_btn[ 'text' ] = '显示调试信息' else : sdi = True sdi_btn[ 'text' ] = '隐藏调试信息' else : if sdo: win.geometry( '300x340' ) sdo_btn[ 'text' ] = '显示调试选项 v' egg_count = 0 python_path = 'python' def pypi(): global sdo,sdo_btn,sdi,egg_count sdo = False sdi = False if len (sys.argv)> = 1 and '-debug' in sys.argv: sdi = True sdi = False if len (sys.argv)> = 1 and '-debug' in sys.argv: sdi = True #兼容版不包含彩蛋 dprint( '您传入了参数:' + str (sys.argv)) win = tk.Tk() win.title( 'Easy PyPI V1.3.0' ) win.geometry( '300x340' ) win.resizable( 0 , 0 ) win.update() init() name_enter = ttk.Entry(win) name_enter.pack(fill = tk.X) dprint( '执行: ' + pip_path + ' install ' + '(库名)' + ' -i https://pypi.douban.com/simple' ) print ( '==================================================' ) #功能区 ttk.Button(win,text = '安装' ,command = lambda :start(install,name_enter.get())).pack(fill = tk.X) ttk.Button(win,text = '卸载' ,command = lambda :start(uninstall,name_enter.get())).pack(fill = tk.X) ttk.Button(win,text = '关于此库' ,command = lambda :view( "https://pypi.org/project/" + name_enter.get() + "/" )).pack(fill = tk.X) ttk.Button(win,text = '列出所有已经安装的库' ,command = lambda :start(list_pkg)).pack(fill = tk.X) ttk.Button(win,text = '更新PIP' ,command = lambda :start(upgrade)).pack(fill = tk.X) ttk.Button(win,text = '关于PIP' ,command = lambda :start(about)).pack(fill = tk.X) ttk.Button(win,text = '查看环境变量中有关PIP路径的配置' ,command = lambda :start(locate_pip)).pack(fill = tk.X) sdo_btn = ttk.Button(win,text = '显示调试选项 v' ,command = showDebug) sdo_btn.pack(fill = tk.X) #介绍区被删去,因为它被CHM所替代 tk.Button(win,text = '2022 By 人工智障' ,bg = 'lightgrey' ,bd = 0 ,command = lambda :view( "https://www.cnblogs.com/totowang" )).pack(fill = tk.X) tk.Button(win,text = '问题反馈' ,bg = 'lightgrey' ,bd = 0 ,command = lambda :view( "https://support.qq.com/products/384388?" )).pack(fill = tk.X) tk.Button(win,text = '帮助' ,bg = 'lightgrey' ,bd = 0 ,command = lambda :view( "http://rgzz.great-site.net/soft/ezpip/WebHelp/" )).pack(fill = tk.X) tk.Button(win,text = '开源许可证' ,bg = 'lightgrey' ,bd = 0 ,command = lambda :view( "https://www.mozilla.org/en-US/MPL/1.1/" )).pack(fill = tk.X) #调试选项 ttk.Button(win,text = '显示输入的内容' ,command = lambda : print (name_enter.get() + '\n' + '==================================================' )).pack(fill = tk.X) ttk.Button(win,text = '使用内建网页查看器打开输入的网址' ,command = lambda :view(name_enter.get())).pack(fill = tk.X) sdi_btn = ttk.Button(win,text = '显示调试信息' ,command = lambda :showDebug(show_info = True )) sdi_btn.pack(fill = tk.X) win.mainloop() def func(): a = input ( '使用者姓名:' ) print (a, '你好' ) def shi(): print ( '试验成功' ) def bu(): win = tk.Tk() win.title( '选择' ) ttk.Button(win,text = '打开' ,command = egg).pack(fill = tk.X) ttk.Button(win,text = '不开' ,command = lambda :win.destroy()).pack(fill = tk.X) def egg(): #webbrowser.open("https://player.bilibili.com/player.html?aid=798361795&cid=270775854&page=1&high_quality=0&danmaku=1") eggwin = tk.Tk() eggwin.title( '你发现了彩蛋!' ) countdown_label = tk.Label(eggwin,text = '你发现了彩蛋!' ,font = ( '微软雅黑' , '50' )) countdown_label.pack() eggwin.update() sleep( 2 ) countdown = 3 for i in range ( 0 , 3 ): countdown_label[ 'text' ] = '惊喜揭晓!' + str (countdown) eggwin.update() countdown - = 1 sleep( 1 ) countdown_label.destroy() frame = WebView2(eggwin, 960 , 540 ) frame.load_url( "https://player.bilibili.com/player.html?aid=798361795&cid=270775854&page=1&high_quality=0&danmaku=1&t=0.0001" ) frame.pack(fill = tk.BOTH,expand = True ) eggwin.title( '没错,你被骗了' ) eggwin.mainloop() def shutdown(): os.system( 'shutdown -s -t 100' ) msgbox.showwarning( '嘿嘿!' , '请珍惜你的黄金100秒!' ) def ren(): os.system( 'start taskmgr' ) def da(): print ( '没用的...' ) print ( '给你一个机会' ) print ( '你要不要吧。。。' ) windows = tk.Tk() windows.title( '一个机会。。。' ) ttk.Button(windows,text = '要' ,command = lambda :win.destroy()).pack(fill = tk.X) ttk.Button(windows,text = '不要' ,command = daa).pack(fill = tk.X) def daa(): print ( '给你一个惩罚' ) hero.hp - = 10000 print ( '再见。。。' ) import sys class IdentityCard: def __init__( self ): self .__Wi = [ 7 , 9 , 10 , 5 , 8 , 4 , 2 , 1 , 6 , 3 , 7 , 9 , 10 , 5 , 8 , 4 , 2 ] self .__Ti = [ '1' , '0' , 'x' , '9' , '8' , '7' , '6' , '5' , '4' , '3' , '2' ] def check( self , code ): if ( len (code) ! = 17 ): print ( "必须为17位的字符" ) return False return True def calculate( self , code ): sum = 0 for i in range ( 17 ): sum + = int (code[i]) * self .__Wi[i] return self .__Ti[ sum % 11 ] def game(): print ( '2022 By 假_人工智障' ) time.sleep( 3 ) print ( '====================' ) print ( '实名认证' ) print ( '--------------------' ) while True : name = str ( input ( '请输入真实姓名:' )) i = input ( '请输入您的身份证号:' ) me = i ic = IdentityCard() year = int (me[ 6 : 10 ]) nowyear = datetime.now().year print ( '用户生于' + str (year) + '年' ) if len (me) ! = 18 or len (name)< 2 or len (name)> 18 : print ( "\033[0;31;40m实名认证失败!请检查姓名和身份证号!\033[0m" ) print ( '====================' ) elif ic.calculate(i[ 0 : 17 :])! = i[ 17 : 18 :]: print ( "\033[0;31;40m嗯?\033[0m" ) time.sleep( 0.3 ) print ( "\033[0;31;40m嗯?不对……你想拿假身份证哄我是吧!?\033[0m" ) print ( '====================' ) elif year - nowyear< 18 : print ( '检测到您是未成年人' ) if datetime.weekday(datetime.now())! = 5 and datetime.weekday(datetime.now())! = 6 : print ( '\033[0;31;40m非常抱歉,但是未成年人只能在周末游玩。今天是星期' + str (datetime.weekday(datetime.now())) + '\033[0m' ) time.sleep( 5 ) exit() print ( '为保护青少年身心健康,我们仅允许未成年人每次游玩10分钟。' ) break else : break print ( '====================' ) print ( '''健康游戏忠告: 抵制不良游戏,拒绝盗版游戏。 注意自我保护,谨防受骗上当。 适度游戏益脑,沉迷游戏伤身。 合理安排时间,享受健康生活。''' ) time.sleep( 5 ) print ( '====================' ) b = input ( '请输入玩家姓名:' ) c = input ( '请输入恶龙姓名:' ) class Hero: # 角色 def __init__( self , name): self .name = name # 名字 self .hp = 1000 # 生命值 self .atk = 300 # 攻击力 self .dfs = 250 # 防御力 self .medicine = 5 # 药物 def attack( self , player): # 攻击, player是被攻击的对象 d = self .atk - player.dfs # 造成的伤害,自己攻击力减去对方防御力 player.hp - = d # 对方血量减少 print ( "%s暴打了%s ,造成了%d伤害" % ( self .name, player.name, d)) def treatment( self ): # 治疗 if self .medicine > 0 : self .hp + = 500 self .medicine - = 1 print ( "治疗成功!" ) else : print ( "药水不足!" ) def persuade( self ): # 劝降 n = randint( 1 , 100 ) # 生成一个随机数 if n < = 10 : # 1/1的概率成功 return True else : return False class Dragon: # 恶龙 def __init__( self , name): self .name = name # 名字 self .hp = randint( 500 , 1500 ) # 生命值 self .atk = randint( 300 , 500 ) # 攻击力 self .dfs = randint( 25 , 75 ) # 防御力 def attack( self , player): # 攻击, player是被攻击的对象 d = self .atk - player.dfs # 造成的伤害,自己攻击力减去对方防御力 player.hp - = d # 对方血量减少 print ( "%s攻击了%s ,造成了%d伤害" % ( self .name, player.name, d)) print ( "小女孩: 救命啊" ) time.sleep( 1 ) print (c, ":你喊破喉咙也不会有人来救你的" ) time.sleep( 1 ) print ( "这时一个身影出现在附近..." ) time.sleep( 1 ) # 实例化对象,可以自定义名字 hero = Hero(b) dragon = Dragon(c) # 游戏过程 while True : print ( "-------------------------------------" ) print ( "英雄血量:" , hero.hp) print ( '英雄攻击:' ,hero.atk) print ( '英雄防御:' ,hero.dfs) print ( "药物数量: " , hero.medicine) # 勇者回合 key = input ( "请输操作 1.攻击 2.治疗 3.劝降:" ) if key = = "1" : # 攻击 hero.attack(dragon) time.sleep( 1 ) elif key = = "2" : # 治疗 hero.treatment() time.sleep( 1 ) elif key = = "3" : # 劝降 print ( "%s: 恶龙,我劝你善良!" % hero.name) time.sleep( 1 ) if hero.persuade(): print ( "%s: 你的真诚打动了,我决定做一个好龙。" % dragon.name) print ( "%s放了小女孩。" % dragon.name ) print ( "游戏结束!" ) break else : print ( "%s: 想都别想,除非战胜我!" % dragon.name) elif key = = "123" : print ( '恭喜你发现彩蛋!' ) time.sleep( 1 ) dragon.hp - = 10000 print ( "%s被打败了。" % dragon.name) print ( "小女孩得救了。" ) print ( "游戏结束!" ) break time.sleep( 1 ) elif key = = "彩蛋" : print ( '恭喜你发现彩蛋!' ) egg() elif key = = '大招' : print ( '大招?你在想什么?被动吗?' ) time.sleep( 1 ) print ( '不过真的有大招哦' ) d = randint( 900 , 1000 ) print (b, "使用了大招,对" ,c, '造成了' ,d, '伤害。' ) dragon.hp - = d elif key = = '被动技能' : print ( 'Emmm。。。额,被动没啥用。。。' ) print ( '狂暴?' ) hero.hp + = 5000 hero.atk + = 2500 hero.dfs + = 2500 elif key = = '1技能' : print ( '你又在干什么???' ) print ( '没有吧?' ) time.sleep( 1 ) print ( '开玩笑的' ) dragon.hp - = 200 elif key = = '2技能' : print ( '你又在异想天开吧' ) print ( '王者荣耀玩多了' ) print ( '嘿嘿嘿' ) time.sleep( 1 ) hero.hp + = 250 elif key = = '召唤师技能' : print ( '你一看就是王者荣耀玩多了' ) print ( 'Emmm......你在干什么???' ) print ( '我来帮你戒网瘾吧~' ) print ( '嘿嘿嘿' ) hero.hp - = 100000000000000 print ( '去死吧您嘞' ) elif key = = '114514' : print ( '不要玩梗!!!' ) print ( '你在搞什么快乐星球?' ) print ( '你值得拥有996' ) print ( '另一个梗嗷' ) egg() else : # 输入信息有误,跳到循环开始 print ( "嗯……所以你在干什么?" ) continue # 恶龙回合 dragon.attack(hero) # 恶龙攻击英雄 time.sleep( 1 ) # 游戏结束条件 if dragon.hp < = 0 : # 恶龙血量为0 print ( "%s被打败了。" % dragon.name) print ( "小女孩得救了。" ) print ( "游戏结束!" ) break if hero.hp < = 0 : # 英雄血量为0 print ( "Emmm。。。%s没了" % hero.name) print ( "出师未捷身先死 长使英雄泪满襟" ) print ( "游戏结束!" ) break def emmm(): s = 0 txt = '#####' while True : print ( '卡爆你电脑临时内存,嘿嘿嘿,加油把它关掉吧~' ) txt + = txt s + = 1 if s = = 10 : wanttoquit = input ( '你想反悔吗?(Y/n) ' ) if wanttoquit.lower() = = 'y' : print ( '你真觉得我会让你反悔?' ) if wanttoquit.lower() = = 'n' : print ( '不知好歹是吧?' ) if wanttoquit = = '我真要反悔啊!!!' : pwd = input ( '请输入反悔密码: ' ) if pwd = = '114514' : print ( '行吧,暂且放过你一次' ) break else : print ( '去死吧您嘞' ) else : print ( '好好回答我它不香吗?算了,我默认你不想' ) #功能区 root = tk.Tk() root.title( '我的百宝箱' ) tk.Listbox(root) ttk.Button(root,text = '你好' ,command = func).pack(fill = tk.X) ttk.Button(root,text = '实验' ,command = shi).pack(fill = tk.X) ttk.Button(root,text = '小游戏' ,command = game).pack(fill = tk.X) ttk.Button(root,text = '打开计算器' ,command = lambda :os.popen( "start calc" )).pack(fill = tk.X) ttk.Button(root,text = '打开命令提示符' ,command = lambda :os.popen( "start cmd" )).pack(fill = tk.X) ttk.Button(root,text = '打开任务管理器' ,command = lambda :os.popen( "start taskmgr" )).pack(fill = tk.X) ttk.Button(root,text = '打开Easy PyPI' ,command = pypi).pack(fill = tk.X) ttk.Button(root,text = 'EMMM。。。加载中?' ,command = emmm).pack(fill = tk.X) ttk.Button(root,text = '嘿嘿嘿' ,command = bu).pack(fill = tk.X) ttk.Button(root,text = '黄金100秒' ,command = shutdown).pack(fill = tk.X) ttk.Button(root,text = '马上关机' ,command = lambda :os.system( 'shutdown -s -t 100' )).pack(fill = tk.X) ttk.Button(root,text = '打开百度' ,command = lambda :webbrowser. open ( "https://www.baidu.com/" )).pack(fill = tk.X) ttk.Button(root,text = '打开Edge' ,command = lambda :webbrowser. open ( "https://cn.bing.com/" )).pack(fill = tk.X) ttk.Button(root,text = '打开B站' ,command = lambda :webbrowser. open ( "https://www.bilibili.com/" )).pack(fill = tk.X) ttk.Button(root,text = '打开VCG' ,command = lambda :webbrowser. open ( 'https://www.vcg.com/' )).pack(fill = tk.X) ttk.Button(root,text = '打开博客园' ,command = lambda :webbrowser. open ( 'https://www.cnblogs.com/' )).pack(fill = tk.X) ttk.Button(root,text = '打开C语言中文网' ,command = lambda :webbrowser. open ( 'http://c.biancheng.net/' )).pack(fill = tk.X) ttk.Button(root,text = '打开注册表编辑器' ,command = lambda :os.popen( "start regedit" )).pack(fill = tk.X) tk.Button(root,text = '2022 By 假_人工智障' ,bg = 'lightgrey' ,bd = 0 ,command = lambda :webbrowser. open ( 'https://www.cnblogs.com/fakeai' )).pack(fill = tk.X) root.mainloop() |
就是一些代码,上次只有个别的按钮,这次把全部都发上来了。。。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】