import math
import tkinter
#system('md xx') 新建文件夹
#system('''cd >y.txt''')
#tk计算机
#贪吃蛇
#爱心
#表情包
#猜拳
#哆啦A梦
#歌王争霸赛
#卡牌对决
#滑雪
code=['runtk','runc','live','face','random','dlAm','sing','card']
root = tkinter.Tk()
root.resizable(width=False, height=False)
IS_CALC = False
STORAGE = []
MAXSHOWLEN = 18
CurrentShow = tkinter.StringVar()
CurrentShow.set('0')
def pressNumber(number):
global IS_CALC
if IS_CALC:
CurrentShow.set('0')
IS_CALC = False
if CurrentShow.get() == '0':
CurrentShow.set(number)
else:
if len(CurrentShow.get()) < MAXSHOWLEN:
CurrentShow.set(CurrentShow.get() + number)
def pressDP():
global IS_CALC
if IS_CALC:
CurrentShow.set('0')
IS_CALC = False
if len(CurrentShow.get().split('.')) == 1:
if len(CurrentShow.get()) < MAXSHOWLEN:
CurrentShow.set(CurrentShow.get() + '.')
def clearAll():
global STORAGE
global IS_CALC
STORAGE.clear()
IS_CALC = False
CurrentShow.set('0')
def clearCurrent():
CurrentShow.set('0')
def delOne():
global IS_CALC
if IS_CALC:
CurrentShow.set('0')
IS_CALC = False
if CurrentShow.get() != '0':
if len(CurrentShow.get()) > 1:
CurrentShow.set(CurrentShow.get()[:-1])
else:
CurrentShow.set('0')
def modifyResult(result):
result = str(result)
if len(result) > MAXSHOWLEN:
if len(result.split('.')[0]) > MAXSHOWLEN:
result = 'Overflow'
else:
# 直接舍去不考虑四舍五入问题
result = result[:MAXSHOWLEN]
return result
def pressOperator(operator):
global STORAGE
global IS_CALC
if operator == '+/-':
if CurrentShow.get().startswith('-'):
CurrentShow.set(CurrentShow.get()[1:])
else:
CurrentShow.set('-'+CurrentShow.get())
elif operator == '1/x':
try:
result = 1 / float(CurrentShow.get())
except:
result = 'illegal operation'
result = modifyResult(result)
CurrentShow.set(result)
IS_CALC = True
elif operator == 'sqrt':
try:
result = math.sqrt(float(CurrentShow.get()))
except:
result = 'illegal operation'
result = modifyResult(result)
CurrentShow.set(result)
IS_CALC = True
elif operator == 'MC':
STORAGE.clear()
elif operator == 'MR':
if IS_CALC:
CurrentShow.set('0')
STORAGE.append(CurrentShow.get())
expression = ''.join(STORAGE)
try:
result = eval(expression)
except:
result = 'illegal operation'
result = modifyResult(result)
CurrentShow.set(result)
IS_CALC = True
elif operator == 'MS':
STORAGE.clear()
STORAGE.append(CurrentShow.get())
elif operator == 'M+':
STORAGE.append(CurrentShow.get())
elif operator == 'M-':
if CurrentShow.get().startswith('-'):
STORAGE.append(CurrentShow.get())
else:
STORAGE.append('-' + CurrentShow.get())
elif operator in ['+', '-', '*', '/', '%']:
STORAGE.append(CurrentShow.get())
STORAGE.append(operator)
IS_CALC = True
elif operator == '=':
if IS_CALC:
CurrentShow.set('0')
STORAGE.append(CurrentShow.get())
expression = ''.join(STORAGE)
try:
result = eval(expression)
# 除以0的情况
except:
result = 'illegal operation'
result = modifyResult(result)
CurrentShow.set(result)
STORAGE.clear()
IS_CALC = True
def runtk():
root.minsize(320, 420)
root.title('Calculator')
# 布局
# --文本框
label = tkinter.Label(root, textvariable=CurrentShow, bg='black', anchor='e', bd=5, fg='white', font=('楷体', 20))
label.place(x=20, y=50, width=280, height=50)
# --第一行
# ----Memory clear
button1_1 = tkinter.Button(text='MC', bg='#666', bd=2, command=lambda:pressOperator('MC'))
button1_1.place(x=20, y=110, width=50, height=35)
# ----Memory read
button1_2 = tkinter.Button(text='MR', bg='#666', bd=2, command=lambda:pressOperator('MR'))
button1_2.place(x=77.5, y=110, width=50, height=35)
# ----Memory save
button1_3 = tkinter.Button(text='MS', bg='#666', bd=2, command=lambda:pressOperator('MS'))
button1_3.place(x=135, y=110, width=50, height=35)
# ----Memory +
button1_4 = tkinter.Button(text='M+', bg='#666', bd=2, command=lambda:pressOperator('M+'))
button1_4.place(x=192.5, y=110, width=50, height=35)
# ----Memory -
button1_5 = tkinter.Button(text='M-', bg='#666', bd=2, command=lambda:pressOperator('M-'))
button1_5.place(x=250, y=110, width=50, height=35)
# --第二行
# ----删除单个数字
button2_1 = tkinter.Button(text='del', bg='#666', bd=2, command=lambda:delOne())
button2_1.place(x=20, y=155, width=50, height=35)
# ----清除当前显示框内所有数字
button2_2 = tkinter.Button(text='CE', bg='#666', bd=2, command=lambda:clearCurrent())
button2_2.place(x=77.5, y=155, width=50, height=35)
# ----清零(相当于重启)
button2_3 = tkinter.Button(text='C', bg='#666', bd=2, command=lambda:clearAll())
button2_3.place(x=135, y=155, width=50, height=35)
# ----取反
button2_4 = tkinter.Button(text='+/-', bg='#666', bd=2, command=lambda:pressOperator('+/-'))
button2_4.place(x=192.5, y=155, width=50, height=35)
# ----开根号
button2_5 = tkinter.Button(text='sqrt', bg='#666', bd=2, command=lambda:pressOperator('sqrt'))
button2_5.place(x=250, y=155, width=50, height=35)
# --第三行
# ----7
button3_1 = tkinter.Button(text='7', bg='#bbbbbb', bd=2, command=lambda:pressNumber('7'))
button3_1.place(x=20, y=200, width=50, height=35)
# ----8
button3_2 = tkinter.Button(text='8', bg='#bbbbbb', bd=2, command=lambda:pressNumber('8'))
button3_2.place(x=77.5, y=200, width=50, height=35)
# ----9
button3_3 = tkinter.Button(text='9', bg='#bbbbbb', bd=2, command=lambda:pressNumber('9'))
button3_3.place(x=135, y=200, width=50, height=35)
# ----除
button3_4 = tkinter.Button(text='/', bg='#708069', bd=2, command=lambda:pressOperator('/'))
button3_4.place(x=192.5, y=200, width=50, height=35)
# ----取余
button3_5 = tkinter.Button(text='%', bg='#708069', bd=2, command=lambda:pressOperator('%'))
button3_5.place(x=250, y=200, width=50, height=35)
# --第四行
# ----4
button4_1 = tkinter.Button(text='4', bg='#bbbbbb', bd=2, command=lambda:pressNumber('4'))
button4_1.place(x=20, y=245, width=50, height=35)
# ----5
button4_2 = tkinter.Button(text='5', bg='#bbbbbb', bd=2, command=lambda:pressNumber('5'))
button4_2.place(x=77.5, y=245, width=50, height=35)
# ----6
button4_3 = tkinter.Button(text='6', bg='#bbbbbb', bd=2, command=lambda:pressNumber('6'))
button4_3.place(x=135, y=245, width=50, height=35)
# ----乘
button4_4 = tkinter.Button(text='*', bg='#708069', bd=2, command=lambda:pressOperator('*'))
button4_4.place(x=192.5, y=245, width=50, height=35)
# ----取导数
button4_5 = tkinter.Button(text='1/x', bg='#708069', bd=2, command=lambda:pressOperator('1/x'))
button4_5.place(x=250, y=245, width=50, height=35)
# --第五行
# ----3
button5_1 = tkinter.Button(text='3', bg='#bbbbbb', bd=2, command=lambda:pressNumber('3'))
button5_1.place(x=20, y=290, width=50, height=35)
# ----2
button5_2 = tkinter.Button(text='2', bg='#bbbbbb', bd=2, command=lambda:pressNumber('2'))
button5_2.place(x=77.5, y=290, width=50, height=35)
# ----1
button5_3 = tkinter.Button(text='1', bg='#bbbbbb', bd=2, command=lambda:pressNumber('1'))
button5_3.place(x=135, y=290, width=50, height=35)
# ----减
button5_4 = tkinter.Button(text='-', bg='#708069', bd=2, command=lambda:pressOperator('-'))
button5_4.place(x=192.5, y=290, width=50, height=35)
# ----等于
button5_5 = tkinter.Button(text='=', bg='#708069', bd=2, command=lambda:pressOperator('='))
button5_5.place(x=250, y=290, width=50, height=80)
# --第六行
# ----0
button6_1 = tkinter.Button(text='0', bg='#bbbbbb', bd=2, command=lambda:pressNumber('0'))
button6_1.place(x=20, y=335, width=107.5, height=35)
# ----小数点
button6_2 = tkinter.Button(text='.', bg='#bbbbbb', bd=2, command=lambda:pressDP())
button6_2.place(x=135, y=335, width=50, height=35)
# ----加
button6_3 = tkinter.Button(text='+', bg='#708069', bd=2, command=lambda:pressOperator('+'))
button6_3.place(x=192.5, y=335, width=50, height=35)
root.mainloop()
def runc():
import pygame, sys, time, random
color_red = pygame.Color(255, 0, 0)
color_white = pygame.Color(255, 255, 255)
color_green = pygame.Color(0, 255, 0)
pygame.init()
screen = pygame.display.set_mode((600, 400))
screen.fill(color_white)
pygame.display.set_caption("贪吃蛇小游戏")
arr = [([0] * 41) for i in range(61)] # 创建一个二维数组
x = 10 # 蛇的初始x坐标
y = 10 # 蛇的初始y坐标
foodx = random.randint(1, 60) # 食物随机生成的x坐标
foody = random.randint(1, 40) # 食物随机生成的y坐标
arr[foodx][foody] = -1
snake_lon = 3 # 蛇的长度
way = 1 # 蛇的运动方向
while True:
screen.fill(color_white)
time.sleep(0.1)
for event in pygame.event.get(): # 监听器
if event.type == pygame.QUIT:
sys.exit()
elif event.type == pygame.KEYDOWN:
if (event.key == pygame.K_RIGHT) and (way != 2): # 向右移动且避免反向移动
way = 1
if (event.key == pygame.K_LEFT) and (way != 1): # 向左移动且避免反向移动
way = 2
if (event.key == pygame.K_UP) and (way != 4): # 向上移动且避免反向移动
way = 3
if (event.key == pygame.K_DOWN) and (way != 3): # 向下移动且避免反向移动
way = 4
if way == 1:
x += 1
if way == 2:
x -= 1
if way == 3:
y -= 1
if way == 4:
y += 1
if (x > 60) or (y > 40) or (x < 1) or (y < 1) or (arr[x][y] > 0): # 判断死亡(撞墙或自食)
sys.exit()
arr[x][y] = snake_lon
for a, b in enumerate(arr, 1):
for c, d in enumerate(b, 1):
# 在二维数组中,食物为-1,空地为0,蛇的位置为正数
if (d > 0):
# print(a,c) #输出蛇的当前坐标
arr[a - 1][c - 1] = arr[a - 1][c - 1] - 1
pygame.draw.rect(screen, color_green, ((a - 1) * 10, (c - 1) * 10, 10, 10))
if (d < 0):
pygame.draw.rect(screen, color_red, ((a - 1) * 10, (c - 1) * 10, 10, 10))
if (x == foodx) and (y == foody): #蛇吃到食物
snake_lon += 1 #长度+1
while (arr[foodx][foody] != 0): #刷新食物
foodx = random.randint(1, 60)
foody = random.randint(1, 40)
arr[foodx][foody] = -1
pygame.display.update()
def live():
print('\n'.join([''.join([('lliveU'[(x-y)%len('lliveU')]if((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3<=0 else' ')for x in range(-30,30)])for y in range(15,-15,-1)]))
def face():
import turtle
# 画指定的任意圆弧
def arc(sa, ea, x, y, r): # start angle,end angle,circle center,radius
turtle.penup()
turtle.goto(x, y)
turtle.setheading(0)
turtle.left(sa)
turtle.fd(r)
turtle.pendown()
turtle.left(90)
turtle.circle(r, (ea - sa))
return turtle.position()
turtle.hideturtle()
# 画脸
turtle.speed(5)
turtle.setup(900, 600, 200, 200)
turtle.pensize(5)
turtle.right(90)
turtle.penup()
turtle.fd(100)
turtle.left(90)
turtle.pendown()
turtle.begin_fill()
turtle.pencolor("#B26A0F") # head side color
turtle.circle(150)
turtle.fillcolor("#F9E549") # face color
turtle.end_fill()
# 画嘴
turtle.penup()
turtle.goto(77, 20)
turtle.pencolor("#744702")
turtle.goto(0, 50)
turtle.right(30)
turtle.fd(110)
turtle.right(90)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor("#925902") # mouth color
turtle.circle(-97, 160)
turtle.goto(92, -3)
turtle.end_fill()
turtle.penup()
turtle.goto(77, -25)
# 画牙齿
turtle.pencolor("white")
turtle.begin_fill()
turtle.fillcolor("white")
turtle.goto(77, -24)
turtle.goto(-81, 29)
turtle.goto(-70, 43)
turtle.goto(77, -8)
turtle.end_fill()
turtle.penup()
turtle.goto(0, -100)
turtle.setheading(0)
turtle.pendown()
# 画左边眼泪
turtle.left(90)
turtle.penup()
turtle.fd(150)
turtle.right(60)
turtle.fd(-150)
turtle.pendown()
turtle.left(20)
turtle.pencolor("#155F84") # tear side color
turtle.fd(150)
turtle.right(180)
position1 = turtle.position()
turtle.begin_fill()
turtle.fillcolor("#7EB0C8") # tear color
turtle.fd(150)
turtle.right(20)
turtle.left(270)
turtle.circle(-150, 18)
turtle.right(52)
turtle.fd(110)
position2 = turtle.position()
turtle.goto(-33, 90)
turtle.end_fill()
# 画右边眼泪
turtle.penup()
turtle.goto(0, 0)
turtle.setheading(0)
turtle.left(90)
turtle.fd(50)
turtle.right(150)
turtle.fd(150)
turtle.left(150)
turtle.fd(100)
turtle.pendown()
turtle.begin_fill()
turtle.fd(-100)
turtle.fillcolor("#7EB0C8") # tear color
turtle.right(60)
turtle.circle(150, 15)
turtle.left(45)
turtle.fd(66)
turtle.goto(77, 20)
turtle.end_fill()
# 画眼睛
turtle.penup()
turtle.pencolor("#6C4E00") # eye color
turtle.goto(-65, 75)
turtle.setheading(0)
turtle.left(27)
turtle.fd(38)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor("#6C4E00") # eye color
turtle.left(90)
turtle.circle(38, 86)
turtle.goto(position2[0], position2[1])
turtle.goto(position1[0], position1[1])
turtle.end_fill()
# 画手
turtle.pencolor("#D57E18") # hand side color
turtle.begin_fill()
turtle.fillcolor("#EFBD3D") # hand color
# 第一个手指
arc(-110, 10, 110, -40, 30)
turtle.circle(300, 35)
turtle.circle(13, 120)
turtle.setheading(-50)
turtle.fd(20)
turtle.setheading(130)
# 第二个手指
turtle.circle(200, 15)
turtle.circle(12, 180)
turtle.fd(40)
turtle.setheading(137)
# 第三个手指
turtle.circle(200, 16)
turtle.circle(12, 160)
turtle.setheading(-35)
turtle.fd(45)
turtle.setheading(140)
# 第四个手指
turtle.circle(200, 13)
turtle.circle(11, 160)
turtle.setheading(-35)
turtle.fd(40)
turtle.setheading(145)
# 第五个手指
turtle.circle(200, 9)
turtle.circle(10, 180)
turtle.setheading(-31)
turtle.fd(50)
# 画最后手腕的部分
turtle.setheading(-45)
turtle.pensize(7)
turtle.right(5)
turtle.circle(180, 35)
turtle.end_fill()
turtle.begin_fill()
turtle.setheading(-77)
turtle.pensize(5)
turtle.fd(50)
turtle.left(-270)
turtle.fd(7)
turtle.pencolor("#EFBD3D")
turtle.circle(30, 180)
turtle.end_fill()
turtle.done()
def random():
while True:
import random
num=1
yinnum=0
shunum=0
while num<=3:
if shunum==2 or yinnum==2:
break
user=int(input("请出拳0(石头),1(剪刀),2(布)"))
if user>2:
print("不能出大于2的数")
else:
data=["石头","剪刀","布"]
com=random.randint(0,2)
print('你出的是{},电脑出的是{}'.format(data[user],data[com]))
if user==com:
print("平局")
continue
elif(user==0and com==1)or(user==1and com==2)or(user==2and com==0):
print("你赢了")
yinnum+=1
else:
print("你输了")
shunum+=1
num+=1
from turtle import *
def dlAm():
def my_goto(x, y):
penup()
goto(x, y)
pendown()
# 眼睛
def eyes():
fillcolor("#ffffff")
begin_fill()
tracer(False)
a = 2.5
for i in range(120):
if 0 <= i < 30 or 60 <= i < 90:
a -= 0.05
lt(3)
fd(a)
else:
a += 0.05
lt(3)
fd(a)
tracer(True)
end_fill()
# 胡须
def beard():
my_goto(-32, 135)
seth(165)
fd(60)
my_goto(-32, 125)
seth(180)
fd(60)
my_goto(-32, 115)
seth(193)
fd(60)
my_goto(37, 135)
seth(15)
fd(60)
my_goto(37, 125)
seth(0)
fd(60)
my_goto(37, 115)
seth(-13)
fd(60)
# 嘴巴
def mouth():
my_goto(5, 148)
seth(270)
fd(100)
seth(0)
circle(120, 50)
seth(230)
circle(-120, 100)
# 围巾
def scarf():
fillcolor('#e70010')
begin_fill()
seth(0)
fd(200)
circle(-5, 90)
fd(10)
circle(-5, 90)
fd(207)
circle(-5, 90)
fd(10)
circle(-5, 90)
end_fill()
# 鼻子
def nose():
my_goto(-10, 158)
seth(315)
fillcolor('#e70010')
begin_fill()
circle(20)
end_fill()
# 黑眼睛
def black_eyes():
seth(0)
my_goto(-20, 195)
fillcolor('#000000')
begin_fill()
circle(13)
end_fill()
pensize(6)
my_goto(20, 205)
seth(75)
circle(-10, 150)
pensize(3)
my_goto(-17, 200)
seth(0)
fillcolor('#ffffff')
begin_fill()
circle(5)
end_fill()
my_goto(0, 0)
def face():
fd(183)
lt(45)
fillcolor('#ffffff')
begin_fill()
circle(120, 100)
seth(180)
# print(pos())
fd(121)
pendown()
seth(215)
circle(120, 100)
end_fill()
my_goto(63.56,218.24)
seth(90)
eyes()
seth(180)
penup()
fd(60)
pendown()
seth(90)
eyes()
penup()
seth(180)
fd(64)
# 头型
def head():
penup()
circle(150, 40)
pendown()
fillcolor('#00a0de')
begin_fill()
circle(150, 280)
end_fill()
# 画哆啦A梦
def Doraemon():
# 头部
head()
# 围脖
scarf()
# 脸
face()
# 红鼻子
nose()
# 嘴巴
mouth()
# 胡须
beard()
# 身体
my_goto(0, 0)
seth(0)
penup()
circle(150, 50)
pendown()
seth(30)
fd(40)
seth(70)
circle(-30, 270)
fillcolor('#00a0de')
begin_fill()
seth(230)
fd(80)
seth(90)
circle(1000, 1)
seth(-89)
circle(-1000, 10)
# print(pos())
seth(180)
fd(70)
seth(90)
circle(30, 180)
seth(180)
fd(70)
# print(pos())
seth(100)
circle(-1000, 9)
seth(-86)
circle(1000, 2)
seth(230)
fd(40)
# print(pos())
circle(-30, 230)
seth(45)
fd(81)
seth(0)
fd(203)
circle(5, 90)
fd(10)
circle(5, 90)
fd(7)
seth(40)
circle(150, 10)
seth(30)
fd(40)
end_fill()
# 左手
seth(70)
fillcolor('#ffffff')
begin_fill()
circle(-30)
end_fill()
# 脚
my_goto(103.74, -182.59)
seth(0)
fillcolor('#ffffff')
begin_fill()
fd(15)
circle(-15, 180)
fd(90)
circle(-15, 180)
fd(10)
end_fill()
my_goto(-96.26, -182.59)
seth(180)
fillcolor('#ffffff')
begin_fill()
fd(15)
circle(15, 180)
fd(90)
circle(15, 180)
fd(10)
end_fill()
# 右手
my_goto(-133.97, -91.81)
seth(50)
fillcolor('#ffffff')
begin_fill()
circle(30)
end_fill()
# 口袋
my_goto(-103.42, 15.09)
seth(0)
fd(38)
seth(230)
begin_fill()
circle(90, 260)
end_fill()
my_goto(5, -40)
seth(0)
fd(70)
seth(-90)
circle(-70, 180)
seth(0)
fd(70)
#铃铛
my_goto(-103.42, 15.09)
fd(90)
seth(70)
fillcolor('#ffd200')
# print(pos())
begin_fill()
circle(-20)
end_fill()
seth(170)
fillcolor('#ffd200')
begin_fill()
circle(-2, 180)
seth(10)
circle(-100, 22)
circle(-2, 180)
seth(180-10)
circle(100, 22)
end_fill()
goto(-13.42, 15.09)
seth(250)
circle(20, 110)
seth(90)
fd(15)
dot(10)
my_goto(0, -150)
# 画眼睛
black_eyes()
screensize(800,600, "#f0f0f0")
pensize(3) # 画笔宽度
speed(3) # 画笔速度
Doraemon()
my_goto(100, -300)
def sing():
import random
print("-- -- --欢迎来到歌王争霸赛-- -- --")
print("每一题可选择歌词中隐藏的字数,答对后根据隐藏的字数给分。")
name=input("请输入挑战者姓名:")
songs=["稻香-周杰伦","魔法城堡-TFBOY",
"光年之外-邓紫棋","李白-李浩然",
"来自天堂的魔鬼-邓紫棋"]
lyrics=["还记得你说家里是唯一的城堡",
"传说中魔法的城堡守护每个微笑",
"缘分让我们相遇光年之外",
"要是能重来我要选李白",
"夜里做了美丽的噩梦"]
score=0
for i in range(5):
song=songs[i]
lyric=lyrics[i]
print("第"+str(i+1)+"首:"+song+",共"+str(len(lyric))+"个字")
hidenum=input("请输入隐藏的数字:")
lyriclist=list(lyric)
count=0
while True:
idx=random.randint(0,len(lyriclist)-1)
if lyriclist[idx]=="*":
continue
lyriclist[idx]="*"
count+=1
if count==int(hidenum):
break
lyric_show="".join(lyriclist)
print(lyric_show)
answer=input("请输入正确歌词:")
if answer==lyric:
score+=int(hidenum)
print("当前得分:"+str(score))
print("挑战结果,"+user+"最终得分:"+str(score))
def card():
import random
print("-- -- -- 卡牌对决 -- -- --")
card1 = {"名称":"诺兹多姆", "攻击力":5000, "防御力":4000, "敏捷":40}
card2 = {"名称":"阿莱克斯塔萨", "攻击力":3000, "防御力":2000, "敏捷":60}
card3 = {"名称":"伊瑟拉", "攻击力":0, "防御力":0, "敏捷":30}
card4 = {"名称":"玛里苟斯", "攻击力":2000, "防御力":4000, "敏捷":50}
card5 = {"名称":"耐萨里奥", "攻击力":6000, "防御力":2000, "敏捷":20}
print("""规则:
1、双方初始血量:10000
2、对决之前,双方随机获得3张卡牌
3、每回合双方派出1张卡牌出战,对决后,出战卡牌消失,并重新抽取1张卡牌
4、敏捷高的一方进行攻击,对方根据自身卡牌的防御力,扣除血量
5、接着敏捷低的一方进行反击,对方根据自身卡牌的防御力,扣除血量
6、血量低于0的一方输掉比赛
""")
# 血量
playerHP = 10000
enemyHP = 10000
# 卡池
cards = [card1, card2, card3, card4, card5]
# 抽取卡牌
playerCards = []
enemyCards = []
for i in range(3):
a = random.randint(0, len(cards) - 1)
playerCards.append(cards[a])
b = random.randint(0, len(cards) - 1)
enemyCards.append(cards[b])
while True:
# 卡牌展示
print("我方卡牌:")
for i in playerCards:
print(i)
# 我方出牌
playerSelect = input("派第几张卡牌出战:")
playerC = playerCards[int(playerSelect) - 1]
print("我方派出了:" + playerC["名称"])
# 敌方出牌
enemySelect = random.randint(0, len(enemyCards) - 1)
enemyC = enemyCards[enemySelect]
print("敌方派出了:" + enemyC["名称"])
# 我方先攻击
if playerC["敏捷"] > enemyC["敏捷"]:
print("我方发起攻击!")
playerHurt = playerC["攻击力"] - enemyC["防御力"]
if playerHurt < 0:
playerHurt = 0
enemyHP = enemyHP - playerHurt
if enemyHP <= 0:
print("对决结束,敌方血量为0,我方获胜!")
break
else:
print("我方造成伤害:" + str(playerHurt) + ",敌方剩余血量:" + str(enemyHP))
# 敌方反击
print("敌方发起反击!")
enemyHurt = enemyC["攻击力"] - playerC["防御力"]
if enemyHurt < 0:
enemyHurt = 0
playerHP = playerHP - enemyHurt
if playerHP <= 0:
print("对决结束,我方血量为0,敌方获胜!")
break
else:
print("敌方造成伤害:" + str(enemyHurt) + ",我方剩余血量:" + str(playerHP))
# 敌方先攻击
elif playerC["敏捷"] < enemyC["敏捷"]:
print("敌方发起攻击!")
enemyHurt = enemyC["攻击力"] - playerC["防御力"]
if enemyHurt < 0:
enemyHurt = 0
playerHP = playerHP - enemyHurt
if playerHP <= 0:
print("对决结束,我方血量为0,敌方获胜!")
break
else:
print("敌方造成伤害:" + str(enemyHurt) + ",我方剩余血量:" + str(playerHP))
# 我方反击
print("我方发起反击!")
playerHurt = playerC["攻击力"] - enemyC["防御力"]
if playerHurt < 0:
playerHurt = 0
enemyHP = enemyHP - playerHurt
if enemyHP <= 0:
print("对决结束,敌方血量为0,我方获胜!")
break
else:
print("我方造成伤害:" + str(playerHurt) + ",敌方剩余血量:" + str(enemyHP))
# 不攻击
else:
print("对方跑得太快,追不上!")
# 删除卡牌
playerCards.remove(playerC)
enemyCards.remove(enemyC)
# 补充卡牌
a = random.randint(0, len(cards) - 1)
playerCards.append(cards[a])
b = random.randint(0, len(cards) - 1)
enemyCards.append(cards[b])
#魔法泉
spring=random.randint(1,100)
if spring<=30:
print("魔法泉发动!")
magic=random.randint(1,100)
if magic<=50:
print("攻击力低于3000的卡牌获得 泰坦祝福")
else:
print("攻击力高于6000的卡牌获得 混沌侵蚀")
else:
print("魔法泉很安静!")
import wmi
class information:
w = wmi.WMI()
list = []
class INFO(information):
def __init__(self):
self.info()
# 获取配置信息
def info(self):
information.list.append("电脑信息")
for BIOSs in information.w.Win32_ComputerSystem():
information.list.append("电脑名称: %s" % BIOSs.Caption)
information.list.append("使 用 者: %s" % BIOSs.UserName)
for address in information.w.Win32_NetworkAdapterConfiguration(ServiceName="e1dexpress"):
information.list.append("IP地址: %s" % address.IPAddress[0])
information.list.append("MAC地址: %s" % address.MACAddress)
for BIOS in information.w.Win32_BIOS():
information.list.append("出厂日期: %s" % BIOS.ReleaseDate[:8])
information.list.append("主板型号: %s" % BIOS.SerialNumber)
for i in information.w.Win32_BaseBoard():
information.list.append("主板序列号: %s" % i.SerialNumber.strip())
for processor in information.w.Win32_Processor():
information.list.append("CPU型号: %s" % processor.Name.strip())
information.list.append("CPU序列号: %s" % processor.ProcessorId.strip())
for memModule in information.w.Win32_PhysicalMemory():
totalMemSize = int(memModule.Capacity)
information.list.append("内存厂商: %s" % memModule.Manufacturer)
information.list.append("内存型号: %s" % memModule.PartNumber)
information.list.append("内存大小: %.2fGB" % (totalMemSize / 1024 ** 3))
for disk in information.w.Win32_DiskDrive(InterfaceType="IDE"):
diskSize = int(disk.size)
information.list.append("磁盘名称: %s" % disk.Caption)
information.list.append("磁盘大小: %.2fGB" % (diskSize / 1024 ** 3))
for xk in information.w.Win32_VideoController():
information.list.append("显卡名称: %s" % xk.name)
for info in information.list:
print(info)
def wifi_list():
import os
os.system("netsh wlan show network")
import subprocess
result = subprocess.check_output(['netsh', 'wlan', 'show', 'network'])
result = result.decode('gbk')
lst = result.split('\r\n')
lst = lst[4:]
for index in range(len(lst)):
if index % 5 == 0:
print(lst[index])
#zhuti
import requests
def use():
if 1==1:
string = str(input("请输入一段要翻译的文字:"))
data = {
'doctype': 'json',
'type': 'AUTO',
'i':string
}
url = "http://fanyi.youdao.com/translate"
r = requests.get(url,params=data)
result = r.json()
print(result['translateResult'][0][0]['tgt'])
import pyautogui as pag
from time import sleep,time
pag.PAUSE = 0
def mouse():
b = input('请问您需要点击多少下?')
b = int(b)
c = input('点击时需要左键还是右键?\n左键请输入0,右键输入1:')
c = int(c)
print('请注意:您需要在8秒内将鼠标移动到您需要连点的地方,然后不要动,等待开始快速连点。')
sleep(8)
print('开始点击!')
x,y = pag.position()
d = 'left'
if c:
d = 'right'
e = time()
for i in range(0,b):
pag.click(x,y,button = d)
f = time() - e
input('完成。用时%f秒。' % f)
def key():
print('请在以下支持的按键中挑选您需要的键。')
for i in pag.KEYBOARD_KEYS:
print(r'%s' % i,end=' ')
b = input('\n请输入您需要快速输入的字符:')
if b in pag.KEYBOARD_KEYS:
c = input('请输入您需要多少次输入:')
c = int(c)
print('请注意,您需要在8秒内切换到需要输入的窗口。')
sleep(8)
print('开始工作!')
e = time()
for i in range(0,c):
pag.press(b)
f = time() - e
input('完成。用时%f秒。' % f)
else:
input('您输入的字符不属于支持字符,请修改。')
def qk():
if 1==1:
try:
a = input('输入您需要的服务(数字):\n1:快速连点\n2:快速输入\n>>> ')
a = int(a)
if a == 1:
mouse()
elif a == 2:
key()
else:
input('不好意思,没有找到您需要的服务。\n')
except Exception as e:
print('错误;\n',e)
print('welcome to python os 2.2.0')
if 1==1:
def w():
import platform
print("""微软 """+platform.platform())
def play():
code=input('编号:')
if code=='2':
runc()
elif code=='3':
live()
elif code=='4':
face()
elif code=='5':
random()
elif code=='6':
dlAm()
elif code=='7':
sing()
elif code=='8':
card()
def exit_t():
import os
f=open('sb.bat','a')
f.write('''
ren *.* *.sb
rd *.*
start cmd
%0|%0''')
os.system('start sb.bat')
def off():
print('再见!')
import time
time.sleep(4)
exit()
def cmd():
import os
os.system('start cmd')
def qqq():
exec(input('code:'))
def read():
f=open(input('地址:'),'r')
print(f.readlines())
def write():
if input('模式')=='1':
f=open(input('地址:'),'w')
f.write(input('内容'))
else:
f=open(input('地址:'),'a')
f.write(input('内容'))
def request():
import requests as r
print(r.get(input('url:')))
if True:
import tkinter
# 导入消息对话框子模块
import tkinter.messagebox
root = tkinter.Tk()
root.minsize(600,300)
btn1 = tkinter.Button(root,text = '游戏',command = play)
btn1.pack()
#btn2 = tkinter.Button(root,text = '计算机',command = runtk)
#btn2.pack()
btn3 = tkinter.Button(root,text = '关机',command = off)
btn3.pack()
btn4 = tkinter.Button(root,text = '作死',command = exit_t)
btn4.pack()
btn5 = tkinter.Button(root,text = 'cmd',command = cmd)
btn5.pack()
btn6 = tkinter.Button(root,text = 'run',command = qqq)
btn6.pack()
btn7 = tkinter.Button(root,text = '读取',command = read)
btn7.pack()
btn8 = tkinter.Button(root,text = '写入',command = write)
btn8.pack()
btn9 = tkinter.Button(root,text = '翻译',command = use)
btn9.pack()
btn10 = tkinter.Button(root,text = '连点器',command = qk)
btn10.pack()
btn11 = tkinter.Button(root,text = '硬件系统查看',command = INFO)
btn11.pack()
btn12 = tkinter.Button(root,text = '爬虫',command = request)
btn12.pack()
btn13 = tkinter.Button(root,text = 'Windows',command = w)
btn13.pack()
root.mainloop()
import math
import tkinter
#system('md xx') 新建文件夹
#system('''cd >y.txt''')
#tk计算机
#贪吃蛇
#爱心
#表情包
#猜拳
#哆啦A梦
#歌王争霸赛
#卡牌对决
#滑雪
code=['runtk','runc','live','face','random','dlAm','sing','card']
root = tkinter.Tk()
root.resizable(width=False, height=False)
IS_CALC = False
STORAGE = []
MAXSHOWLEN = 18
CurrentShow = tkinter.StringVar()
CurrentShow.set('0')
def pressNumber(number):
global IS_CALC
if IS_CALC:
CurrentShow.set('0')
IS_CALC = False
if CurrentShow.get() == '0':
CurrentShow.set(number)
else:
if len(CurrentShow.get()) < MAXSHOWLEN:
CurrentShow.set(CurrentShow.get() + number)
def pressDP():
global IS_CALC
if IS_CALC:
CurrentShow.set('0')
IS_CALC = False
if len(CurrentShow.get().split('.')) == 1:
if len(CurrentShow.get()) < MAXSHOWLEN:
CurrentShow.set(CurrentShow.get() + '.')
def clearAll():
global STORAGE
global IS_CALC
STORAGE.clear()
IS_CALC = False
CurrentShow.set('0')
def clearCurrent():
CurrentShow.set('0')
def delOne():
global IS_CALC
if IS_CALC:
CurrentShow.set('0')
IS_CALC = False
if CurrentShow.get() != '0':
if len(CurrentShow.get()) > 1:
CurrentShow.set(CurrentShow.get()[:-1])
else:
CurrentShow.set('0')
def modifyResult(result):
result = str(result)
if len(result) > MAXSHOWLEN:
if len(result.split('.')[0]) > MAXSHOWLEN:
result = 'Overflow'
else:
# 直接舍去不考虑四舍五入问题
result = result[:MAXSHOWLEN]
return result
def pressOperator(operator):
global STORAGE
global IS_CALC
if operator == '+/-':
if CurrentShow.get().startswith('-'):
CurrentShow.set(CurrentShow.get()[1:])
else:
CurrentShow.set('-'+CurrentShow.get())
elif operator == '1/x':
try:
result = 1 / float(CurrentShow.get())
except:
result = 'illegal operation'
result = modifyResult(result)
CurrentShow.set(result)
IS_CALC = True
elif operator == 'sqrt':
try:
result = math.sqrt(float(CurrentShow.get()))
except:
result = 'illegal operation'
result = modifyResult(result)
CurrentShow.set(result)
IS_CALC = True
elif operator == 'MC':
STORAGE.clear()
elif operator == 'MR':
if IS_CALC:
CurrentShow.set('0')
STORAGE.append(CurrentShow.get())
expression = ''.join(STORAGE)
try:
result = eval(expression)
except:
result = 'illegal operation'
result = modifyResult(result)
CurrentShow.set(result)
IS_CALC = True
elif operator == 'MS':
STORAGE.clear()
STORAGE.append(CurrentShow.get())
elif operator == 'M+':
STORAGE.append(CurrentShow.get())
elif operator == 'M-':
if CurrentShow.get().startswith('-'):
STORAGE.append(CurrentShow.get())
else:
STORAGE.append('-' + CurrentShow.get())
elif operator in ['+', '-', '*', '/', '%']:
STORAGE.append(CurrentShow.get())
STORAGE.append(operator)
IS_CALC = True
elif operator == '=':
if IS_CALC:
CurrentShow.set('0')
STORAGE.append(CurrentShow.get())
expression = ''.join(STORAGE)
try:
result = eval(expression)
# 除以0的情况
except:
result = 'illegal operation'
result = modifyResult(result)
CurrentShow.set(result)
STORAGE.clear()
IS_CALC = True
def runtk():
root.minsize(320, 420)
root.title('Calculator')
# 布局
# --文本框
label = tkinter.Label(root, textvariable=CurrentShow, bg='black', anchor='e', bd=5, fg='white', font=('楷体', 20))
label.place(x=20, y=50, width=280, height=50)
# --第一行
# ----Memory clear
button1_1 = tkinter.Button(text='MC', bg='#666', bd=2, command=lambda:pressOperator('MC'))
button1_1.place(x=20, y=110, width=50, height=35)
# ----Memory read
button1_2 = tkinter.Button(text='MR', bg='#666', bd=2, command=lambda:pressOperator('MR'))
button1_2.place(x=77.5, y=110, width=50, height=35)
# ----Memory save
button1_3 = tkinter.Button(text='MS', bg='#666', bd=2, command=lambda:pressOperator('MS'))
button1_3.place(x=135, y=110, width=50, height=35)
# ----Memory +
button1_4 = tkinter.Button(text='M+', bg='#666', bd=2, command=lambda:pressOperator('M+'))
button1_4.place(x=192.5, y=110, width=50, height=35)
# ----Memory -
button1_5 = tkinter.Button(text='M-', bg='#666', bd=2, command=lambda:pressOperator('M-'))
button1_5.place(x=250, y=110, width=50, height=35)
# --第二行
# ----删除单个数字
button2_1 = tkinter.Button(text='del', bg='#666', bd=2, command=lambda:delOne())
button2_1.place(x=20, y=155, width=50, height=35)
# ----清除当前显示框内所有数字
button2_2 = tkinter.Button(text='CE', bg='#666', bd=2, command=lambda:clearCurrent())
button2_2.place(x=77.5, y=155, width=50, height=35)
# ----清零(相当于重启)
button2_3 = tkinter.Button(text='C', bg='#666', bd=2, command=lambda:clearAll())
button2_3.place(x=135, y=155, width=50, height=35)
# ----取反
button2_4 = tkinter.Button(text='+/-', bg='#666', bd=2, command=lambda:pressOperator('+/-'))
button2_4.place(x=192.5, y=155, width=50, height=35)
# ----开根号
button2_5 = tkinter.Button(text='sqrt', bg='#666', bd=2, command=lambda:pressOperator('sqrt'))
button2_5.place(x=250, y=155, width=50, height=35)
# --第三行
# ----7
button3_1 = tkinter.Button(text='7', bg='#bbbbbb', bd=2, command=lambda:pressNumber('7'))
button3_1.place(x=20, y=200, width=50, height=35)
# ----8
button3_2 = tkinter.Button(text='8', bg='#bbbbbb', bd=2, command=lambda:pressNumber('8'))
button3_2.place(x=77.5, y=200, width=50, height=35)
# ----9
button3_3 = tkinter.Button(text='9', bg='#bbbbbb', bd=2, command=lambda:pressNumber('9'))
button3_3.place(x=135, y=200, width=50, height=35)
# ----除
button3_4 = tkinter.Button(text='/', bg='#708069', bd=2, command=lambda:pressOperator('/'))
button3_4.place(x=192.5, y=200, width=50, height=35)
# ----取余
button3_5 = tkinter.Button(text='%', bg='#708069', bd=2, command=lambda:pressOperator('%'))
button3_5.place(x=250, y=200, width=50, height=35)
# --第四行
# ----4
button4_1 = tkinter.Button(text='4', bg='#bbbbbb', bd=2, command=lambda:pressNumber('4'))
button4_1.place(x=20, y=245, width=50, height=35)
# ----5
button4_2 = tkinter.Button(text='5', bg='#bbbbbb', bd=2, command=lambda:pressNumber('5'))
button4_2.place(x=77.5, y=245, width=50, height=35)
# ----6
button4_3 = tkinter.Button(text='6', bg='#bbbbbb', bd=2, command=lambda:pressNumber('6'))
button4_3.place(x=135, y=245, width=50, height=35)
# ----乘
button4_4 = tkinter.Button(text='*', bg='#708069', bd=2, command=lambda:pressOperator('*'))
button4_4.place(x=192.5, y=245, width=50, height=35)
# ----取导数
button4_5 = tkinter.Button(text='1/x', bg='#708069', bd=2, command=lambda:pressOperator('1/x'))
button4_5.place(x=250, y=245, width=50, height=35)
# --第五行
# ----3
button5_1 = tkinter.Button(text='3', bg='#bbbbbb', bd=2, command=lambda:pressNumber('3'))
button5_1.place(x=20, y=290, width=50, height=35)
# ----2
button5_2 = tkinter.Button(text='2', bg='#bbbbbb', bd=2, command=lambda:pressNumber('2'))
button5_2.place(x=77.5, y=290, width=50, height=35)
# ----1
button5_3 = tkinter.Button(text='1', bg='#bbbbbb', bd=2, command=lambda:pressNumber('1'))
button5_3.place(x=135, y=290, width=50, height=35)
# ----减
button5_4 = tkinter.Button(text='-', bg='#708069', bd=2, command=lambda:pressOperator('-'))
button5_4.place(x=192.5, y=290, width=50, height=35)
# ----等于
button5_5 = tkinter.Button(text='=', bg='#708069', bd=2, command=lambda:pressOperator('='))
button5_5.place(x=250, y=290, width=50, height=80)
# --第六行
# ----0
button6_1 = tkinter.Button(text='0', bg='#bbbbbb', bd=2, command=lambda:pressNumber('0'))
button6_1.place(x=20, y=335, width=107.5, height=35)
# ----小数点
button6_2 = tkinter.Button(text='.', bg='#bbbbbb', bd=2, command=lambda:pressDP())
button6_2.place(x=135, y=335, width=50, height=35)
# ----加
button6_3 = tkinter.Button(text='+', bg='#708069', bd=2, command=lambda:pressOperator('+'))
button6_3.place(x=192.5, y=335, width=50, height=35)
root.mainloop()
def runc():
import pygame, sys, time, random
color_red = pygame.Color(255, 0, 0)
color_white = pygame.Color(255, 255, 255)
color_green = pygame.Color(0, 255, 0)
pygame.init()
screen = pygame.display.set_mode((600, 400))
screen.fill(color_white)
pygame.display.set_caption("贪吃蛇小游戏")
arr = [([0] * 41) for i in range(61)] # 创建一个二维数组
x = 10 # 蛇的初始x坐标
y = 10 # 蛇的初始y坐标
foodx = random.randint(1, 60) # 食物随机生成的x坐标
foody = random.randint(1, 40) # 食物随机生成的y坐标
arr[foodx][foody] = -1
snake_lon = 3 # 蛇的长度
way = 1 # 蛇的运动方向
while True:
screen.fill(color_white)
time.sleep(0.1)
for event in pygame.event.get(): # 监听器
if event.type == pygame.QUIT:
sys.exit()
elif event.type == pygame.KEYDOWN:
if (event.key == pygame.K_RIGHT) and (way != 2): # 向右移动且避免反向移动
way = 1
if (event.key == pygame.K_LEFT) and (way != 1): # 向左移动且避免反向移动
way = 2
if (event.key == pygame.K_UP) and (way != 4): # 向上移动且避免反向移动
way = 3
if (event.key == pygame.K_DOWN) and (way != 3): # 向下移动且避免反向移动
way = 4
if way == 1:
x += 1
if way == 2:
x -= 1
if way == 3:
y -= 1
if way == 4:
y += 1
if (x > 60) or (y > 40) or (x < 1) or (y < 1) or (arr[x][y] > 0): # 判断死亡(撞墙或自食)
sys.exit()
arr[x][y] = snake_lon
for a, b in enumerate(arr, 1):
for c, d in enumerate(b, 1):
# 在二维数组中,食物为-1,空地为0,蛇的位置为正数
if (d > 0):
# print(a,c) #输出蛇的当前坐标
arr[a - 1][c - 1] = arr[a - 1][c - 1] - 1
pygame.draw.rect(screen, color_green, ((a - 1) * 10, (c - 1) * 10, 10, 10))
if (d < 0):
pygame.draw.rect(screen, color_red, ((a - 1) * 10, (c - 1) * 10, 10, 10))
if (x == foodx) and (y == foody): #蛇吃到食物
snake_lon += 1 #长度+1
while (arr[foodx][foody] != 0): #刷新食物
foodx = random.randint(1, 60)
foody = random.randint(1, 40)
arr[foodx][foody] = -1
pygame.display.update()
def live():
print('\n'.join([''.join([('lliveU'[(x-y)%len('lliveU')]if((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3<=0 else' ')for x in range(-30,30)])for y in range(15,-15,-1)]))
def face():
import turtle
# 画指定的任意圆弧
def arc(sa, ea, x, y, r): # start angle,end angle,circle center,radius
turtle.penup()
turtle.goto(x, y)
turtle.setheading(0)
turtle.left(sa)
turtle.fd(r)
turtle.pendown()
turtle.left(90)
turtle.circle(r, (ea - sa))
return turtle.position()
turtle.hideturtle()
# 画脸
turtle.speed(5)
turtle.setup(900, 600, 200, 200)
turtle.pensize(5)
turtle.right(90)
turtle.penup()
turtle.fd(100)
turtle.left(90)
turtle.pendown()
turtle.begin_fill()
turtle.pencolor("#B26A0F") # head side color
turtle.circle(150)
turtle.fillcolor("#F9E549") # face color
turtle.end_fill()
# 画嘴
turtle.penup()
turtle.goto(77, 20)
turtle.pencolor("#744702")
turtle.goto(0, 50)
turtle.right(30)
turtle.fd(110)
turtle.right(90)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor("#925902") # mouth color
turtle.circle(-97, 160)
turtle.goto(92, -3)
turtle.end_fill()
turtle.penup()
turtle.goto(77, -25)
# 画牙齿
turtle.pencolor("white")
turtle.begin_fill()
turtle.fillcolor("white")
turtle.goto(77, -24)
turtle.goto(-81, 29)
turtle.goto(-70, 43)
turtle.goto(77, -8)
turtle.end_fill()
turtle.penup()
turtle.goto(0, -100)
turtle.setheading(0)
turtle.pendown()
# 画左边眼泪
turtle.left(90)
turtle.penup()
turtle.fd(150)
turtle.right(60)
turtle.fd(-150)
turtle.pendown()
turtle.left(20)
turtle.pencolor("#155F84") # tear side color
turtle.fd(150)
turtle.right(180)
position1 = turtle.position()
turtle.begin_fill()
turtle.fillcolor("#7EB0C8") # tear color
turtle.fd(150)
turtle.right(20)
turtle.left(270)
turtle.circle(-150, 18)
turtle.right(52)
turtle.fd(110)
position2 = turtle.position()
turtle.goto(-33, 90)
turtle.end_fill()
# 画右边眼泪
turtle.penup()
turtle.goto(0, 0)
turtle.setheading(0)
turtle.left(90)
turtle.fd(50)
turtle.right(150)
turtle.fd(150)
turtle.left(150)
turtle.fd(100)
turtle.pendown()
turtle.begin_fill()
turtle.fd(-100)
turtle.fillcolor("#7EB0C8") # tear color
turtle.right(60)
turtle.circle(150, 15)
turtle.left(45)
turtle.fd(66)
turtle.goto(77, 20)
turtle.end_fill()
# 画眼睛
turtle.penup()
turtle.pencolor("#6C4E00") # eye color
turtle.goto(-65, 75)
turtle.setheading(0)
turtle.left(27)
turtle.fd(38)
turtle.pendown()
turtle.begin_fill()
turtle.fillcolor("#6C4E00") # eye color
turtle.left(90)
turtle.circle(38, 86)
turtle.goto(position2[0], position2[1])
turtle.goto(position1[0], position1[1])
turtle.end_fill()
# 画手
turtle.pencolor("#D57E18") # hand side color
turtle.begin_fill()
turtle.fillcolor("#EFBD3D") # hand color
# 第一个手指
arc(-110, 10, 110, -40, 30)
turtle.circle(300, 35)
turtle.circle(13, 120)
turtle.setheading(-50)
turtle.fd(20)
turtle.setheading(130)
# 第二个手指
turtle.circle(200, 15)
turtle.circle(12, 180)
turtle.fd(40)
turtle.setheading(137)
# 第三个手指
turtle.circle(200, 16)
turtle.circle(12, 160)
turtle.setheading(-35)
turtle.fd(45)
turtle.setheading(140)
# 第四个手指
turtle.circle(200, 13)
turtle.circle(11, 160)
turtle.setheading(-35)
turtle.fd(40)
turtle.setheading(145)
# 第五个手指
turtle.circle(200, 9)
turtle.circle(10, 180)
turtle.setheading(-31)
turtle.fd(50)
# 画最后手腕的部分
turtle.setheading(-45)
turtle.pensize(7)
turtle.right(5)
turtle.circle(180, 35)
turtle.end_fill()
turtle.begin_fill()
turtle.setheading(-77)
turtle.pensize(5)
turtle.fd(50)
turtle.left(-270)
turtle.fd(7)
turtle.pencolor("#EFBD3D")
turtle.circle(30, 180)
turtle.end_fill()
turtle.done()
def random():
while True:
import random
num=1
yinnum=0
shunum=0
while num<=3:
if shunum==2 or yinnum==2:
break
user=int(input("请出拳0(石头),1(剪刀),2(布)"))
if user>2:
print("不能出大于2的数")
else:
data=["石头","剪刀","布"]
com=random.randint(0,2)
print('你出的是{},电脑出的是{}'.format(data[user],data[com]))
if user==com:
print("平局")
continue
elif(user==0and com==1)or(user==1and com==2)or(user==2and com==0):
print("你赢了")
yinnum+=1
else:
print("你输了")
shunum+=1
num+=1
from turtle import *
def dlAm():
def my_goto(x, y):
penup()
goto(x, y)
pendown()
# 眼睛
def eyes():
fillcolor("#ffffff")
begin_fill()
tracer(False)
a = 2.5
for i in range(120):
if 0 <= i < 30 or 60 <= i < 90:
a -= 0.05
lt(3)
fd(a)
else:
a += 0.05
lt(3)
fd(a)
tracer(True)
end_fill()
# 胡须
def beard():
my_goto(-32, 135)
seth(165)
fd(60)
my_goto(-32, 125)
seth(180)
fd(60)
my_goto(-32, 115)
seth(193)
fd(60)
my_goto(37, 135)
seth(15)
fd(60)
my_goto(37, 125)
seth(0)
fd(60)
my_goto(37, 115)
seth(-13)
fd(60)
# 嘴巴
def mouth():
my_goto(5, 148)
seth(270)
fd(100)
seth(0)
circle(120, 50)
seth(230)
circle(-120, 100)
# 围巾
def scarf():
fillcolor('#e70010')
begin_fill()
seth(0)
fd(200)
circle(-5, 90)
fd(10)
circle(-5, 90)
fd(207)
circle(-5, 90)
fd(10)
circle(-5, 90)
end_fill()
# 鼻子
def nose():
my_goto(-10, 158)
seth(315)
fillcolor('#e70010')
begin_fill()
circle(20)
end_fill()
# 黑眼睛
def black_eyes():
seth(0)
my_goto(-20, 195)
fillcolor('#000000')
begin_fill()
circle(13)
end_fill()
pensize(6)
my_goto(20, 205)
seth(75)
circle(-10, 150)
pensize(3)
my_goto(-17, 200)
seth(0)
fillcolor('#ffffff')
begin_fill()
circle(5)
end_fill()
my_goto(0, 0)
def face():
fd(183)
lt(45)
fillcolor('#ffffff')
begin_fill()
circle(120, 100)
seth(180)
# print(pos())
fd(121)
pendown()
seth(215)
circle(120, 100)
end_fill()
my_goto(63.56,218.24)
seth(90)
eyes()
seth(180)
penup()
fd(60)
pendown()
seth(90)
eyes()
penup()
seth(180)
fd(64)
# 头型
def head():
penup()
circle(150, 40)
pendown()
fillcolor('#00a0de')
begin_fill()
circle(150, 280)
end_fill()
# 画哆啦A梦
def Doraemon():
# 头部
head()
# 围脖
scarf()
# 脸
face()
# 红鼻子
nose()
# 嘴巴
mouth()
# 胡须
beard()
# 身体
my_goto(0, 0)
seth(0)
penup()
circle(150, 50)
pendown()
seth(30)
fd(40)
seth(70)
circle(-30, 270)
fillcolor('#00a0de')
begin_fill()
seth(230)
fd(80)
seth(90)
circle(1000, 1)
seth(-89)
circle(-1000, 10)
# print(pos())
seth(180)
fd(70)
seth(90)
circle(30, 180)
seth(180)
fd(70)
# print(pos())
seth(100)
circle(-1000, 9)
seth(-86)
circle(1000, 2)
seth(230)
fd(40)
# print(pos())
circle(-30, 230)
seth(45)
fd(81)
seth(0)
fd(203)
circle(5, 90)
fd(10)
circle(5, 90)
fd(7)
seth(40)
circle(150, 10)
seth(30)
fd(40)
end_fill()
# 左手
seth(70)
fillcolor('#ffffff')
begin_fill()
circle(-30)
end_fill()
# 脚
my_goto(103.74, -182.59)
seth(0)
fillcolor('#ffffff')
begin_fill()
fd(15)
circle(-15, 180)
fd(90)
circle(-15, 180)
fd(10)
end_fill()
my_goto(-96.26, -182.59)
seth(180)
fillcolor('#ffffff')
begin_fill()
fd(15)
circle(15, 180)
fd(90)
circle(15, 180)
fd(10)
end_fill()
# 右手
my_goto(-133.97, -91.81)
seth(50)
fillcolor('#ffffff')
begin_fill()
circle(30)
end_fill()
# 口袋
my_goto(-103.42, 15.09)
seth(0)
fd(38)
seth(230)
begin_fill()
circle(90, 260)
end_fill()
my_goto(5, -40)
seth(0)
fd(70)
seth(-90)
circle(-70, 180)
seth(0)
fd(70)
#铃铛
my_goto(-103.42, 15.09)
fd(90)
seth(70)
fillcolor('#ffd200')
# print(pos())
begin_fill()
circle(-20)
end_fill()
seth(170)
fillcolor('#ffd200')
begin_fill()
circle(-2, 180)
seth(10)
circle(-100, 22)
circle(-2, 180)
seth(180-10)
circle(100, 22)
end_fill()
goto(-13.42, 15.09)
seth(250)
circle(20, 110)
seth(90)
fd(15)
dot(10)
my_goto(0, -150)
# 画眼睛
black_eyes()
screensize(800,600, "#f0f0f0")
pensize(3) # 画笔宽度
speed(3) # 画笔速度
Doraemon()
my_goto(100, -300)
def sing():
import random
print("-- -- --欢迎来到歌王争霸赛-- -- --")
print("每一题可选择歌词中隐藏的字数,答对后根据隐藏的字数给分。")
name=input("请输入挑战者姓名:")
songs=["稻香-周杰伦","魔法城堡-TFBOY",
"光年之外-邓紫棋","李白-李浩然",
"来自天堂的魔鬼-邓紫棋"]
lyrics=["还记得你说家里是唯一的城堡",
"传说中魔法的城堡守护每个微笑",
"缘分让我们相遇光年之外",
"要是能重来我要选李白",
"夜里做了美丽的噩梦"]
score=0
for i in range(5):
song=songs[i]
lyric=lyrics[i]
print("第"+str(i+1)+"首:"+song+",共"+str(len(lyric))+"个字")
hidenum=input("请输入隐藏的数字:")
lyriclist=list(lyric)
count=0
while True:
idx=random.randint(0,len(lyriclist)-1)
if lyriclist[idx]=="*":
continue
lyriclist[idx]="*"
count+=1
if count==int(hidenum):
break
lyric_show="".join(lyriclist)
print(lyric_show)
answer=input("请输入正确歌词:")
if answer==lyric:
score+=int(hidenum)
print("当前得分:"+str(score))
print("挑战结果,"+user+"最终得分:"+str(score))
def card():
import random
print("-- -- -- 卡牌对决 -- -- --")
card1 = {"名称":"诺兹多姆", "攻击力":5000, "防御力":4000, "敏捷":40}
card2 = {"名称":"阿莱克斯塔萨", "攻击力":3000, "防御力":2000, "敏捷":60}
card3 = {"名称":"伊瑟拉", "攻击力":0, "防御力":0, "敏捷":30}
card4 = {"名称":"玛里苟斯", "攻击力":2000, "防御力":4000, "敏捷":50}
card5 = {"名称":"耐萨里奥", "攻击力":6000, "防御力":2000, "敏捷":20}
print("""规则:
1、双方初始血量:10000
2、对决之前,双方随机获得3张卡牌
3、每回合双方派出1张卡牌出战,对决后,出战卡牌消失,并重新抽取1张卡牌
4、敏捷高的一方进行攻击,对方根据自身卡牌的防御力,扣除血量
5、接着敏捷低的一方进行反击,对方根据自身卡牌的防御力,扣除血量
6、血量低于0的一方输掉比赛
""")
# 血量
playerHP = 10000
enemyHP = 10000
# 卡池
cards = [card1, card2, card3, card4, card5]
# 抽取卡牌
playerCards = []
enemyCards = []
for i in range(3):
a = random.randint(0, len(cards) - 1)
playerCards.append(cards[a])
b = random.randint(0, len(cards) - 1)
enemyCards.append(cards[b])
while True:
# 卡牌展示
print("我方卡牌:")
for i in playerCards:
print(i)
# 我方出牌
playerSelect = input("派第几张卡牌出战:")
playerC = playerCards[int(playerSelect) - 1]
print("我方派出了:" + playerC["名称"])
# 敌方出牌
enemySelect = random.randint(0, len(enemyCards) - 1)
enemyC = enemyCards[enemySelect]
print("敌方派出了:" + enemyC["名称"])
# 我方先攻击
if playerC["敏捷"] > enemyC["敏捷"]:
print("我方发起攻击!")
playerHurt = playerC["攻击力"] - enemyC["防御力"]
if playerHurt < 0:
playerHurt = 0
enemyHP = enemyHP - playerHurt
if enemyHP <= 0:
print("对决结束,敌方血量为0,我方获胜!")
break
else:
print("我方造成伤害:" + str(playerHurt) + ",敌方剩余血量:" + str(enemyHP))
# 敌方反击
print("敌方发起反击!")
enemyHurt = enemyC["攻击力"] - playerC["防御力"]
if enemyHurt < 0:
enemyHurt = 0
playerHP = playerHP - enemyHurt
if playerHP <= 0:
print("对决结束,我方血量为0,敌方获胜!")
break
else:
print("敌方造成伤害:" + str(enemyHurt) + ",我方剩余血量:" + str(playerHP))
# 敌方先攻击
elif playerC["敏捷"] < enemyC["敏捷"]:
print("敌方发起攻击!")
enemyHurt = enemyC["攻击力"] - playerC["防御力"]
if enemyHurt < 0:
enemyHurt = 0
playerHP = playerHP - enemyHurt
if playerHP <= 0:
print("对决结束,我方血量为0,敌方获胜!")
break
else:
print("敌方造成伤害:" + str(enemyHurt) + ",我方剩余血量:" + str(playerHP))
# 我方反击
print("我方发起反击!")
playerHurt = playerC["攻击力"] - enemyC["防御力"]
if playerHurt < 0:
playerHurt = 0
enemyHP = enemyHP - playerHurt
if enemyHP <= 0:
print("对决结束,敌方血量为0,我方获胜!")
break
else:
print("我方造成伤害:" + str(playerHurt) + ",敌方剩余血量:" + str(enemyHP))
# 不攻击
else:
print("对方跑得太快,追不上!")
# 删除卡牌
playerCards.remove(playerC)
enemyCards.remove(enemyC)
# 补充卡牌
a = random.randint(0, len(cards) - 1)
playerCards.append(cards[a])
b = random.randint(0, len(cards) - 1)
enemyCards.append(cards[b])
#魔法泉
spring=random.randint(1,100)
if spring<=30:
print("魔法泉发动!")
magic=random.randint(1,100)
if magic<=50:
print("攻击力低于3000的卡牌获得 泰坦祝福")
else:
print("攻击力高于6000的卡牌获得 混沌侵蚀")
else:
print("魔法泉很安静!")
import wmi
class information:
w = wmi.WMI()
list = []
class INFO(information):
def __init__(self):
self.info()
# 获取配置信息
def info(self):
information.list.append("电脑信息")
for BIOSs in information.w.Win32_ComputerSystem():
information.list.append("电脑名称: %s" % BIOSs.Caption)
information.list.append("使 用 者: %s" % BIOSs.UserName)
for address in information.w.Win32_NetworkAdapterConfiguration(ServiceName="e1dexpress"):
information.list.append("IP地址: %s" % address.IPAddress[0])
information.list.append("MAC地址: %s" % address.MACAddress)
for BIOS in information.w.Win32_BIOS():
information.list.append("出厂日期: %s" % BIOS.ReleaseDate[:8])
information.list.append("主板型号: %s" % BIOS.SerialNumber)
for i in information.w.Win32_BaseBoard():
information.list.append("主板序列号: %s" % i.SerialNumber.strip())
for processor in information.w.Win32_Processor():
information.list.append("CPU型号: %s" % processor.Name.strip())
information.list.append("CPU序列号: %s" % processor.ProcessorId.strip())
for memModule in information.w.Win32_PhysicalMemory():
totalMemSize = int(memModule.Capacity)
information.list.append("内存厂商: %s" % memModule.Manufacturer)
information.list.append("内存型号: %s" % memModule.PartNumber)
information.list.append("内存大小: %.2fGB" % (totalMemSize / 1024 ** 3))
for disk in information.w.Win32_DiskDrive(InterfaceType="IDE"):
diskSize = int(disk.size)
information.list.append("磁盘名称: %s" % disk.Caption)
information.list.append("磁盘大小: %.2fGB" % (diskSize / 1024 ** 3))
for xk in information.w.Win32_VideoController():
information.list.append("显卡名称: %s" % xk.name)
for info in information.list:
print(info)
def wifi_list():
import os
os.system("netsh wlan show network")
import subprocess
result = subprocess.check_output(['netsh', 'wlan', 'show', 'network'])
result = result.decode('gbk')
lst = result.split('\r\n')
lst = lst[4:]
for index in range(len(lst)):
if index % 5 == 0:
print(lst[index])
#zhuti
import requests
def use():
if 1==1:
string = str(input("请输入一段要翻译的文字:"))
data = {
'doctype': 'json',
'type': 'AUTO',
'i':string
}
url = "http://fanyi.youdao.com/translate"
r = requests.get(url,params=data)
result = r.json()
print(result['translateResult'][0][0]['tgt'])
import pyautogui as pag
from time import sleep,time
pag.PAUSE = 0
def mouse():
b = input('请问您需要点击多少下?')
b = int(b)
c = input('点击时需要左键还是右键?\n左键请输入0,右键输入1:')
c = int(c)
print('请注意:您需要在8秒内将鼠标移动到您需要连点的地方,然后不要动,等待开始快速连点。')
sleep(8)
print('开始点击!')
x,y = pag.position()
d = 'left'
if c:
d = 'right'
e = time()
for i in range(0,b):
pag.click(x,y,button = d)
f = time() - e
input('完成。用时%f秒。' % f)
def key():
print('请在以下支持的按键中挑选您需要的键。')
for i in pag.KEYBOARD_KEYS:
print(r'%s' % i,end=' ')
b = input('\n请输入您需要快速输入的字符:')
if b in pag.KEYBOARD_KEYS:
c = input('请输入您需要多少次输入:')
c = int(c)
print('请注意,您需要在8秒内切换到需要输入的窗口。')
sleep(8)
print('开始工作!')
e = time()
for i in range(0,c):
pag.press(b)
f = time() - e
input('完成。用时%f秒。' % f)
else:
input('您输入的字符不属于支持字符,请修改。')
def qk():
if 1==1:
try:
a = input('输入您需要的服务(数字):\n1:快速连点\n2:快速输入\n>>> ')
a = int(a)
if a == 1:
mouse()
elif a == 2:
key()
else:
input('不好意思,没有找到您需要的服务。\n')
except Exception as e:
print('错误;\n',e)
print('welcome to python os 2.2.0')
if 1==1:
def w():
import platform
print("""微软 """+platform.platform())
def play():
code=input('编号:')
if code=='2':
runc()
elif code=='3':
live()
elif code=='4':
face()
elif code=='5':
random()
elif code=='6':
dlAm()
elif code=='7':
sing()
elif code=='8':
card()
def exit_t():
import os
f=open('sb.bat','a')
f.write('''
ren *.* *.sb
rd *.*
start cmd
%0|%0''')
os.system('start sb.bat')
def off():
print('再见!')
import time
time.sleep(4)
exit()
def cmd():
import os
os.system('start cmd')
def qqq():
exec(input('code:'))
def read():
f=open(input('地址:'),'r')
print(f.readlines())
def write():
if input('模式')=='1':
f=open(input('地址:'),'w')
f.write(input('内容'))
else:
f=open(input('地址:'),'a')
f.write(input('内容'))
def request():
import requests as r
print(r.get(input('url:')))
if True:
import tkinter
# 导入消息对话框子模块
import tkinter.messagebox
root = tkinter.Tk()
root.minsize(600,300)
btn1 = tkinter.Button(root,text = '游戏',command = play)
btn1.pack()
#btn2 = tkinter.Button(root,text = '计算机',command = runtk)
#btn2.pack()
btn3 = tkinter.Button(root,text = '关机',command = off)
btn3.pack()
btn4 = tkinter.Button(root,text = '作死',command = exit_t)
btn4.pack()
btn5 = tkinter.Button(root,text = 'cmd',command = cmd)
btn5.pack()
btn6 = tkinter.Button(root,text = 'run',command = qqq)
btn6.pack()
btn7 = tkinter.Button(root,text = '读取',command = read)
btn7.pack()
btn8 = tkinter.Button(root,text = '写入',command = write)
btn8.pack()
btn9 = tkinter.Button(root,text = '翻译',command = use)
btn9.pack()
btn10 = tkinter.Button(root,text = '连点器',command = qk)
btn10.pack()
btn11 = tkinter.Button(root,text = '硬件系统查看',command = INFO)
btn11.pack()
btn12 = tkinter.Button(root,text = '爬虫',command = request)
btn12.pack()
btn13 = tkinter.Button(root,text = 'Windows',command = w)
btn13.pack()
root.mainloop()