Python can do a lot of boring, but interesting things, such as the following examples.
Python trick program
-
- One of the boring programs
- Boring program number two
- Boring program number three
- Boring program number four
- Boring program number five
- Pyinstaller coding bugs
- It’s done. Creative moment
The following procedures, do not send code, or can not achieve the purpose of your prank.
Package it into an EXE program and send it to a friend.
Use PIP Install PyInstaller.
The package command is as follows:
Pyinstaller -f Filename.pyCopy the code
If there is a BUG (usually a coding error), click the navigation to see the solution
One of the boring programs
While True: n = input(" Guess what I'm thinking?" ) print(" Guess wrong ")Copy the code
Your friends will never know what you’re thinking.
Of course, after I installed the 360, the program was gone. If you are interested in learning about no-kill, you can like this article 100 times and eraser a Python no-kill tutorial.
The sky is blue and there are thousands of paper cranes outside the window
Trick your friends with Python with 10 boring Python programs
Boring program number two
Siming popup window
The import tkinter. Messagebox while True: tkinter messagebox. Showerror (' Windows error ', 'your computer under attack! ')Copy the code
After running, very exciting, if the other side will not kill the process, even more exciting.
20210109220541647.png
The sky is blue and there are thousands of paper cranes outside the window
Boring program number three
Call the default browser, open CSDN unlimited, let him love learning.
import webbrowser
while True:
webbrowser.open('www.csdn.net')
Copy the code
Well, after using it, eraser’s own computer crashed.
Trick your friends with Python with 10 boring Python programs
The instant CPU…
20210109220920479.png
The sky is blue and there are thousands of paper cranes outside the window
Boring program number four
This program is much more dynamic, will randomly pop up.
import tkinter as tk import random import threading import time def boom(): window = tk.Tk() width = window.winfo_screenwidth() height = window.winfo_screenheight() a = random.randrange(0, width) b = random.randrange(0, Height) window.title(' you are a foolish roe deer ') window.geometry("200x50" +" + STR (a) +" +" + STR (b)) tk.label (window, Text = 'you are a silly roe deer, bg =' green ', the font = (' song typeface, 17), width = 20. height=4).pack() window.mainloop() threads = [] for i in range(100): T = threading. Thread (target = boom) threads. Append (t) time. Sleep (0.1) threads [I] the start ()Copy the code
The running effect is shown in the picture below, which is very exciting and can be modified at will. [Image upload failed…(image-9ba135-1610635489885)]
The sky is blue and there are thousands of paper cranes outside the window
Boring program number five
The program could be no. 1 in erasers, and could even be combined with the current hot gun Maotai case.
import os import time a = """ oooo oooooooooo. .oooooo.. o oooo o8o oooo oooo `888 `888' `Y8b d8P' `Y8 `888 `"' `888 `888 888 888 888 Y88bo. .ooooo. .ooooo. 888 oooo oooo 888 888 888 888 888 `"Y8888o. d88' `88b d88' `"Y8 888 .8P' `888 888 888 888 888 888 8888888 `"Y88b 888ooo888 888 888888\. 888 888 888 888 888 d88' oo .d8P 888 .o 888 .o8 888 `88b. 888 888 888 .o. 88P o888bood8P' 8""88888P' `Y8bod8P' `Y8bod8P' O888o o888O o888O o888O O888O O888O Y888P Functions: 1. "" print(a) key = input(" please select ") if key == "1": Print (' not available ') print(' not available ') else: print(' not available ') print(' not available ') ) time.sleep(3) print(" ~~~~~") os.system('shutdown -r-t 10') time.sleep(10)Copy the code
The sky is blue, there are thousands of paper cranes outside the window don’t run, run after don’t blame me.
Pyinstaller coding bugs
The following error occurs when using PyInstaller to package the EXE:
File "c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 68, in __exec_python_cmd
txt = exec_python(*cmd, env=pp_env)
File "c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\compat.py", line 526, in exec_python
return exec_command(*cmdargs, **kwargs)
File "c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\compat.py", line 321, in exec_command
out = out.decode(encoding)
AttributeError: 'str' object has no attribute 'decode'
Copy the code
Screenshot below:
Modify the following code as indicated by the BUG:
Out = out. Decode (encoding) # change to out = outCopy the code
Package success in the DIST file to find exe program.
20210109220105322.png
If you are interested in Python, please add QQ: 3145679695