赞
踩
因为在学习这些代码的时候是有业务在身,代码来源已经不再可以追溯,因此以下的这些代码除展示的效果即图片外的所有内容,如在网上其他地方有类似,一定是本博主抄人家的。 像各位致敬。本人只起了汇总作用!
效果是随机的0和1从左向右逐次展示在命令提示符上
效果:
@echo off
CAPI
set CAPI=API Call user32 GetSystemMetrics ;0
set /a x=%CAPI_Ret%+21
set CAPI=API Call user32 GetSystemMetrics ;1
set /a y=%CAPI_Ret%+59
mode con cols=%x% lines=%y%
set CAPI=API Call kernel32 GetConsoleWindow
set hCMD=%CAPI_Ret%
set CAPI=API Call user32 SetWindowPos ;%hCMD% ;-1 ;0 ;0 ;0 ;0 ;3
set CAPI=API Call user32 MoveWindow ;%hCMD% ;-6 ;-25 ;%x% ;%y% ;1
pause
代码来自百度贴吧:怎样将bat显示窗口全屏化?
效果是将一些伪代码一行一行的展示出来,从上向下逐行展示在命令提示符上
效果:
@echo off
setlocal ENABLEDELAYEDEXPANSION
title=牛逼的名称
mode con cols=120 lines=150
color A
REM 伪代码或 K-means 算法示例
set "code_line[1]=parser = transformers.HfArgumentParser((ModelArguments, DataArguments, TrainingArguments))"
set "code_line[2]=model_args, data_args, training_args = parser.parse_args_into_dataclasses()"
set "code_line[3]=model = transformers.AutoModelForCausalLM.from_pretrained()"
set "code_line[4]=tokenizer = transformers.AutoTokenizer.from_pretrained()"
set "code_line[5]= if tokenizer.pad_token is None:"
set "code_line[6]= if 'llama' in model_args.model_name_or_path:"
set "code_line[7]=data_module = make_supervised_data_module(tokenizer=tokenizer, data_args=data_args)"
set "code_line[8]=trainer = Trainer(model=model, tokenizer=tokenizer, args=training_args, **data_module)"
set "code_line[9]=trainer.train()"
set "code_line[10]=trainer.save_state()"
set "code_line[11]=safe_save_model_for_hf_trainer(trainer=trainer, output_dir=training_args.output_dir)"
set "code_line[12]=if __name__ == '__main__':"
set "code_line[13]=train()"
set "code_line[14]=Encoding basic Python object hierarchies::"
set "code_line[15]= >>> import json"
set "code_line[16]=Compact encoding::>>> json.dumps([1,2,3,mydict], separators=(',', ':'))"
set "code_line[17]=Pretty printing:: >>> import json>>> print(json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4))"
set "code_line[18]= if cls is None:"
set "code_line[19]= if cls is None:"
set "code_line[20]=copier = _deepcopy_dispatch.get(cls)y = _reconstruct(x, memo, *rv)"
set "code_line[21]=parser = transformers.HfArgumentParser((ModelArguments, DataArguments, TrainingArguments))"
set "code_line[22]=model_args, data_args, training_args = parser.parse_args_into_dataclasses()"
set "code_line[23]=model = transformers.AutoModelForCausalLM.from_pretrained()"
set "code_line[24]=tokenizer = transformers.AutoTokenizer.from_pretrained()"
set "code_line[25]= if tokenizer.pad_token is None:"
set "code_line[26]= if 'llama' in model_args.model_name_or_path:"
set "code_line[27]=data_module = make_supervised_data_module(tokenizer=tokenizer, data_args=data_args)"
set "code_line[28]=trainer = Trainer(model=model, tokenizer=tokenizer, args=training_args, **data_module)"
set "code_line[29]=trainer.train()"
set "code_line[30]=trainer.save_state()"
set "code_line[31]=safe_save_model_for_hf_trainer(trainer=trainer, output_dir=training_args.output_dir)"
set "code_line[32]=if __name__ == '__main__':"
set "code_line[33]=train()"
set "code_line[34]=Encoding basic Python object hierarchies::"
set "code_line[35]= >>> import json"
set "code_line[36]=Compact encoding::>>> json.dumps([1,2,3,mydict], separators=(',', ':'))"
set "code_line[37]=Pretty printing:: >>> import json>>> print(json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4))"
set "code_line[38]= if cls is None:"
set "code_line[39]= if cls is None:"
set "code_line[40]=copier = _deepcopy_dispatch.get(cls)y = _reconstruct(x, memo, *rv)"
set "code_line[41]=safe_save_model_for_hf_trainer(trainer=trainer, output_dir=training_args.output_dir)"
set "code_line[42]=if __name__ == '__main__':"
set "code_line[43]=train()"
set "code_line[44]=Encoding basic Python object hierarchies::"
set "code_line[45]= >>> import json"
set "code_line[46]=Compact encoding::>>> json.dumps([1,2,3,mydict], separators=(',', ':'))"
set "code_line[47]=Pretty printing:: >>> import json>>> print(json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4))"
set "code_line[48]= if cls is None:"
set "code_line[49]= if cls is None:"
set "code_line[50]=copier = _deepcopy_dispatch.get(cls)y = _reconstruct(x, memo, *rv)"
REM 输出代码文本
for /l %%i in (1,1,50) do (
echo !code_line[%%i]!
Wscript sleep.vbs
)
sleep.vbs文件内容(用来控制每行代码展示的速度):
WScript.sleep 100
import random
import pygame
PANEL_width = 1440
PANEL_highly = 900
FONT_PX = 15
pygame.init()
winSur = pygame.display.set_mode((PANEL_width, PANEL_highly))
font = pygame.font.SysFont("123.ttf", 25)
bg_suface = pygame.Surface((PANEL_width, PANEL_highly), flags=pygame.SRCALPHA)
pygame.Surface.convert(bg_suface)
bg_suface.fill(pygame.Color(0, 0, 0, 28))
winSur.fill((0, 0, 0))
letter = ["0", "1"] # 这里改成什么,就会掉落什么
texts = [font.render(str(letter[i]), True, (0, 255, 0)) for i in range(len(letter))]
column = int(PANEL_width / FONT_PX)
drops = [0 for i in range(column)]
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
pygame.time.delay(30)
winSur.blit(bg_suface, (0, 0))
for i in range(len(drops)):
text = random.choice(texts)
winSur.blit(text, (i * FONT_PX, drops[i] * FONT_PX))
drops[i] += 1
if drops[i] * 10 > PANEL_highly or random.random() > 0.95:
drops[i] = 0
pygame.display.flip()
要想达到运行bat文件之后,命令提示符能暂停1秒再退出,可以使用以下命令实现:
timeout /t 1 > nul
怎么改命令提示符的一些配置看下面:
1、.bat文件设置窗口标题、窗口大小、字体及背景颜色?
2、BAT批处理修改MSDOS窗口标题、大小、字体及背景颜色
0=黑色 1=蓝色 2=绿色 3=湖蓝色 4=红色 5=紫色 6=黄色 7=白色 8=灰色
9=淡蓝色 A=淡绿色 B=淡蓝绿色 C=淡红色 D=淡紫色 E=淡黄色 F=亮白色
3、Windows Bat实现延时功能的几种常见方式
效果
代码
import pygame
import random
# 初始化 Pygame
pygame.init()
# 设置屏幕大小和标题
screen_width = 800
screen_height = 600
screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption('弹幕')
# 设置字体和字号
font = pygame.font.SysFont('Arial', 30)
# 生成随机颜色
def random_color():
return (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
# 弹幕类
class Danmu:
def __init__(self, text):
self.text = text
self.color = random_color()
self.x = screen_width
self.y = random.randint(0, screen_height)
self.speed = random.randint(5, 10)
# 更新弹幕位置
def update(self):
self.x -= self.speed
# 绘制弹幕
def draw(self):
text_surface = font.render(self.text, True, self.color)
screen.blit(text_surface, (self.x, self.y))
# 存储弹幕的列表
danmu_list = []
# 游戏循环
running = True
while running:
# 处理事件
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# 生成新的弹幕
if random.randint(0, 100) < 10:
# danmu = Danmu('弹幕')
danmu = Danmu('111') # 更换这里的111为想往里面的放的弹幕
danmu_list.append(danmu)
# 更新弹幕位置
for danmu in danmu_list:
danmu.update()
# 绘制背景和弹幕
screen.fill((255, 255, 255))
for danmu in danmu_list:
danmu.draw()
# 更新屏幕
pygame.display.update()
# 退出 Pygame
pygame.quit()
效果
代码
import pygame
import pprint
def main():
# 初始化pygame
pygame.init()
# 初始化字体模块
pygame.font.init()
# 如果字体模块已初始化,则为true
print('是否初始化', pygame.font.get_init())
# 获取默认字体的文件名
print('默认字体名', pygame.font.get_default_font())
# 获取所有可用的字体
pprint.pprint(pygame.font.get_fonts())
# 在系统上找到特定的字体
# print('查找字体', pygame.font.match_font('arial'))
# 从系统字体创建一个Font对象
# (名称,大小,粗体=假,斜体=假) - >字体
a = pygame.font.SysFont('幼圆', 50)
# 从文件或对象绘制文本
# pygame.font.Font('文件或对象',大小)
# 在新Surface上绘制文本
# 显示内容、是否消除锯齿、字体颜色、背景颜色
text = a.render("1giao wo li giao~", True, (255, 0, 0), (0, 0, 0))
# 取消初始化字体模块
# pygame.font.quit()
# 设置屏幕
screen = pygame.display.set_mode((500, 100))
# 设置矩形区域
ztx, zty, ztw, zth = text.get_rect()
# 绘制显示文字的矩形区域
jx = pygame.Rect(500, 50 - zth / 2, ztw, zth) # 初始位置设置屏幕右边,并居住显示,2/1屏幕的高度 - 2/1字体的高度 向上移动是减
# 设置游戏时钟
clock = pygame.time.Clock()
while True:
# 文字滚动的频率
clock.tick(30)
# 重绘屏幕
screen.fill((0, 0, 0))
# 退出事件
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
exit(0)
# 文字从右向左移动
jx.x -= 5
# 如果字体全部移动出屏幕,则设置字体X轴位置为510, 500的话会出现的比较突然
if jx.x < 0 - ztw:
jx.x = 510
# 屏幕绘制字体,
screen.blit(text, [jx.x, jx.y])
# 更新屏幕显示
pygame.display.update()
if __name__ == '__main__':
main()
代码
import pygame
import sys
pygame.init()
# 设置窗口尺寸
win_size = (800, 600)
screen = pygame.display.set_mode(win_size)
pygame.display.set_caption("文字显示示例")
# 设置字体和文字内容
# font = pygame.font.SysFont(None, 48) # 使用系统默认字体,字号为48
font = pygame.font.SysFont(None, 36) # 使用系统默认字体,字号为48
text = font.render("Hello, World!", True, (255, 255, 255)) # 渲染文字表面
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
screen.fill((0, 0, 0)) # 填充屏幕为黑色
screen.blit(text, (200, 200)) # 在指定位置绘制文字
pygame.display.update()
# for i in text:
# screen.blit(i, (200, 200)) # 在指定位置绘制文字
# import time
# time.sleep(5)
# pygame.display.update()
效果
代码:
import tkinter as tk
import random
import threading
import time
def dow():
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("400x100"+"+"+str(a)+"+"+str(b))
tk.Label(window,
text='新年快乐!!!',
bg='pink',
font=('楷体',23),
width=40, height=15).pack()
window.mainloop()
threads=[]
for i in range(15): # 这里修改弹出的弹窗的个数
t=threading.Thread(target=dow)
threads.append(t)
time.sleep(0.1)
threads[i].start()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。