當前位置: 妍妍網 > 碼農

python黑客裝逼神器!

2024-01-27碼農

大家好!給你們帶來了幾個實用黑客特效例項,可以在朋友面前展示一下自己。

基礎例項:

import osfor root, dirs, files in os.walk('/'):for directory indirs:print(os.path.join(root, directory))

2.0:

import osfrom colorama import init, Fore, Back, style# 初始化 colorama 模組init()for root, dirs, files in os.walk('/'):for directory in dirs:print(Fore.GREEN + os.path.join(root, directory))

3.0:

import osimport randomimport timefrom colorama import init, Fore, Back, style# 初始化 colorama 模組init()defprint_hacker_ style(text):for char in text:if char == " ": print(char, end='', flush=True) time.sleep(0.01)else: print(Fore.GREEN + str(random.randint(0, 1)), end='', flush=True) time.sleep(0.01) print( style.RESET_ALL)for root, dirs, files in os.walk('/'):for directory in dirs: path = os.path.join(root, directory) print_hacker_ style(path)

黑客帝國效果:

import osimport randomimport timeimport shutilfrom colorama import init, Fore# 初始化 colorama 模組init()# 獲取終端視窗的大小defget_terminal_size(): columns, rows = shutil.get_terminal_size()return rows, columns# 清屏並定位光標位置defreset_screen_position(rows, columns): print('\033[{};{}H'.format(rows, 1), end='', flush=True)# 清屏defclear_screen():if os.name == 'nt': os.system('cls')else: os.system('clear')# 輸出隨機字元defprint_random_char(): chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*', '#', '^', '&', '%'] colors = [Fore.GREEN, Fore.WHITE, Fore.CYAN, Fore.LIGHTGREEN_EX] random_char = random.choice(chars) random_color = random.choice(colors) print(random_color + random_char, end='', flush=True)# 主程式defrun_program(): clear_screen()whileTrue: rows, columns = get_terminal_size() reset_screen_position(rows, columns)for i in range(rows * columns): print_random_char() time.sleep(0.1)run_program()

裝逼神器:

import timefrom colorama import init, Fore, stylefrom faker import Fakerinit() # 初始化 coloramadefprint_effect(text):for char in text: print(Fore.GREEN + char, end="", flush=True) time.sleep(0.05) print( style.RESET_ALL) # 恢復終端顏色# 建立 faker 物件fake = Faker()# 生成和打印隨機資訊whileTrue:# 隨機生成資訊 name = fake.name() address = fake.address() phone_number = fake.phone_number()# 將資訊合並成一個字串,並在開頭和結尾使用 "-" 進行框起來 info = f"姓名: {name}\n 地址: {address}\n 電話: {phone_number} "# 使用特效打印資訊 print_effect(info)# 使用 "$$" 進行分隔 print(Fore.YELLOW + "$$" + style.RESET_ALL)