Python can do a lot of boring, but interesting things, such as the following examples.

Python trick program

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 File name.py 1Copy 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 ") 123Copy 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

Boring program number two

Siming popup window

The import tkinter. Messagebox while True: tkinter messagebox. Showerror (' Windows error ', 'your computer under attack! 1234 ')Copy the code

After running, very exciting, if the other side will not kill the process, even more exciting.

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')
123
Copy the code

Well, after using it, eraser’s own computer crashed.

The instant CPU…

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 () 12345678910111213141516171819202122232425Copy the code

The running effect is shown in the picture below, which is very exciting and can be modified at will.

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) 123456789101112131415161718192021222324252627282930313233Copy the code

The sky is blue and there are thousands of paper cranes outside the window

Don’t run it. Don’t blame me when you run it.

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'
1234567
Copy the code

Screenshot below:



Modify the following code as indicated by the BUG:

Out = out.decode(encoding) # change to out = out 1Copy the code

Package success indistLook in the filesexeProcedure.

And that’s it for today,If you are interested in Python, please join us.Python Learning communicationSkirt 】, receive free learning materials and source code.