Python can do a lot of boring but interesting things, such as the next few cases.
Python tricky program
The following program, do not post code, or it will not achieve your tricky purpose.
To be packaged into a exe
program, it is interesting to friends.
Many people learn python and don't know where to start.
Many people learn python and after mastering the basic grammar, they don't know where to find cases to get started.
Many people who have done case studies do not know how to learn more advanced knowledge.
For these three types of people, I will provide you with a good learning platform, free to receive video tutorials, e-books, and course source code! ??¤
QQ group: 232030553
Use pip install pyinstaller
.
The packaging commands are as follows:
pyinstaller -F 文件名.py
If there is a BUG (usually a coding error) during the process, click the navigation to view the solution
One of the boring programs
while True:
n = input("猜猜我在想啥?")
print("猜错喽")
Your friends will never know what you are thinking.
Of course, after I installed 360, the program disappeared. If you are interested in researching anti-killing, you can give this article a thumbs up, like over 100, the eraser will give you a Python anti-killing tutorial.
The sky is blue and there are paper cranes outside the window
The second boring program
Doom popup
import tkinter.messagebox
while True:
tkinter.messagebox.showerror('Windows 错误','你的电脑正在被攻击!')
After running, it is very exciting, if the other party does not kill the process, it is even more exciting.
The sky is blue and there are paper cranes outside the window
The third boring program
Call the default browser, open CSDN unlimited, let him fall in love with learning.
import webbrowser
while True:
webbrowser.open('www.csdn.net')
Uh, after using it, the eraser's own computer crashed.
Instantly CPU...
The sky is blue and there are paper cranes outside the window
Boring program 4
This program is more dynamic, and pop-up windows will appear randomly.
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('你是一个傻狍子')
window.geometry("200x50" + "+" + str(a) + "+" + str(b))
tk.Label(window, text='你是一个傻狍子', bg='green',
font=('宋体', 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].start()
The running effect is shown in the figure below, which is very exciting and can be modified at will.
The sky is blue and there are paper cranes outside the window
The fifth boring program
This program ranks first in the eraser's opinion, and can even be combined with the most popular gun Moutai 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
`Y888P
功能列表:
1.预约商品
2.秒杀抢购商品
"""
print(a)
key = input("请选择:")
if key == "1":
time.sleep(1.5)
print('没有预约到\n')
time.sleep(3)
print('没事的,来抱一哈\n')
else:
print("既然如此...")
time.sleep(3)
print("那你想得美~~~~~")
os.system('shutdown -r -t 10')
time.sleep(10)
The sky is blue and there are paper cranes outside the window
Don't run, don't blame me after running.
pyinstaller coding bug
In use pyinstaller
, when packaged exe, the following error occurs:
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'
The screenshot is as follows:
According to the location of the BUG prompt, modify the following code:
out = out.decode(encoding) # 改为 out = out
Packaging Success in dist
finding file exe
procedures.