猫史档案馆


挽风不会甩狙

挽风不会甩狙

Lv.1

获赞:8收藏:0浏览:8作品收藏:0
回复帖子评论
上一页1 页 / 共 1下一页

【Python作品分享】冰墩墩 中回复

有个叫静静的人已经比你先发布过了

2022-04-05T16:20:30 点赞:0

【pygame:飞机大战】教你用pygame开发游戏 Part8 中回复

imgsrc="https://static.codemao.cn/emoji/codemao/%E7%BC%96%E7%A8%8B%E7%8C%AB_%E7%82%B9%E8%B5%9E.gif"alt="emotion_编程猫_点赞"

2022-04-09T17:21:57 点赞:0

python计算器 中回复

#导入模块 import re import tkinter, tkinter.messagebox
#创建窗口 window = tkinter.Tk() window.geometry('300x270+400+100') window.resizable(False, False) window.title('计算器')
#定义按钮功能与不规范操作提醒 def ButtonOperation(m): theme = themeVar.get() if theme.startswith('.'): theme = '0'+theme if m in'0123456789': theme += m elif m == '.': Segmentationpart = re.split(r'\+|-|\*|/',theme)[-1] if'.'in Segmentationpart: tkinter.messagebox.showerror('错误', '重复出现的小数点') return else: theme += m elif m =='C': theme = '' elif m in operators: if theme.endswith(operators): thinter.messagebox.showerror('错误', '不允许存在连续运算符') return theme += m elif m == 'Sqrt': n = theme.split('.') ifall(map(lambda x:x.isdigit(), n)): theme = eval(theme)**0.5 else: tkinter.messagebox.showerror('错误', '算式错误') return elif m =='=': try: theme = str(eval(theme)) except: tkinter.messagebox.showerror('错误', '算式错误') return themeVar.set(theme)
#放置文本框 themeVar = tkinter.StringVar(window, '') themeEntry = tkinter.Entry(window, textvariable=themeVar) themeEntry['state'] = 'readonly' themeEntry.place(x=10, y=10, width=280, height=20)
#放置按钮 figure = list('0123456789.')+['Sqet'] index = 0 for row in range(4): for col inrange(3): a = figure[index] index += 1 m_figure = tkinter.Button(window, text=a, command=lambda x=a:ButtonOperation(x)) m_figure.place(x=20+col*70, y=80+row*50, width=50, heidgt=20) operators = ('+', '-', '*', '/', '**', '//') for index,operators in enumerate(operators): m_figure = tkinter.Button(window, text=operators, bg='or-ange', command=lambda x=operators:ButtonOperation(x)) m_operator.place(x=230, y=80+index*30, width=50, height=20) m_Clear = tkinter.Button(window, text='C', bg='red', command=lambda:ButtonOperation('C')) m_Clear.place(x=40, y=40, width=80,height=20) m_EqualSign = tkinter.Button(window, text='=', bg='yellow', command=lambda:ButtonOperation('=')) m_EqualSign.place(x=170, y=40, width=80, height=20)
window.mainloop()

2022-04-17T07:58:43 点赞:0

【代码岛3.0指令包】传奇喵的700行指令包来了! 中回复

这是python还是Java

2022-05-07T18:19:14 点赞:0