猫史档案馆


蒟蒻OIer1048576

蒟蒻OIer1048576

Lv.1

只是喜欢Python而已……徒弟:程序侯

获赞:206收藏:39浏览:2002作品收藏:29

签名:只是喜欢Python而已…… 徒弟:程序侯

回复帖子评论
上一页10 页 / 共 60下一页

计算器20.0代码曝光! 中回复

from tkinter import *
import easygui
import math
w = Tk()
equation,final = StringVar(),StringVar()
def func_set(name):
    a = easygui.integerbox("数1?")
    b = easygui.integerbox("数2?")
    equation.set(f"{name}("+equation.get()+f"{a},{b})")
def lcm(x, y):
    greater = x if x > y else y
    while greater % x == 0 and greater % y == 0: greater += 1
    return greater
def gcd(x, y):
    喵aller = x if x < y else y
    hcf = [i for i in range(1,喵aller+1) if x % i == 0 and y % i == 0][-1]
    return hcf
def num(n):
    equation.set(equation.get() + str(n))
sin,cos,tan = lambda n: math.sin(math.radians(n)),lambda n: math.cos(math.radians(n)),lambda n: math.tan(math.radians(n))
sinh,cosh,tanh = math.sin,math.cos,math.tan
asin,acos,atan = math.asin,math.acos,math.atan
deg,rad,sqrt = math.degrees,math.radians,math.sqrt
binary,october,hexadecimal = lambda n: bin(n)[2:],lambda n: oct(n)[2:],lambda n: hex(n)[2:]
ln,log,log2 = math.log,math.log10,math.log2
π,e,fact = math.pi,math.e,math.factorial
decimal_fraction = lambda n: n - int(n)
def ce():
    equation.set('')
    final.set('')
def calculate():
    try:
        final.set(f"={str(eval(equation.get().replace('×','*').replace('÷','/').replace('^','**').replace('mod','%')))}")
    except Exception:
        easygui.exceptionbox()
        ce()
def function(name):
    equation.set(name + '(' + equation.get() + ')')
w.geometry('1500x1000')
Button(w, text=0, command=lambda: num(0), width=7, height=2, font=('Arial',20)).grid(row=1,column=0)
Button(w, text=1, command=lambda: num(1), width=7, height=2, font=('Arial',20)).grid(row=1,column=1)
Button(w, text=2, command=lambda: num(2), width=7, height=2, font=('Arial',20)).grid(row=1,column=2)
Button(w, text=3, command=lambda: num(3), width=7, height=2, font=('Arial',20)).grid(row=2,column=0)
Button(w, text=4, command=lambda: num(4), width=7, height=2, font=('Arial',20)).grid(row=2,column=1)
Button(w, text=5, command=lambda: num(5), width=7, height=2, font=('Arial',20)).grid(row=2,column=2)
Button(w, text=6, command=lambda: num(6), width=7, height=2, font=('Arial',20)).grid(row=3,column=0)
Button(w, text=7, command=lambda: num(7), width=7, height=2, font=('Arial',20)).grid(row=3,column=1)
Button(w, text=8, command=lambda: num(8), width=7, height=2, font=('Arial',20)).grid(row=3,column=2)
Button(w, text=9, command=lambda: num(9), width=7, height=2, font=('Arial',20)).grid(row=4,column=1)
Button(w, text='.', command=lambda: num('.'), width=7, height=2, font=('Arial',20)).grid(row=5,column=3)
Button(w, text='+', command=lambda: num('+'), width=7, height=2, font=('Arial',20)).grid(row=1, column=3)
Button(w, text='-', command=lambda: num('-'), width=7, height=2, font=('Arial',20)).grid(row=2, column=3)
Button(w, text='×', command=lambda: num('×'), width=7, height=2, font=('Arial',20)).grid(row=3, column=3)
Button(w, text='÷', command=lambda: num('÷'), width=7, height=2, font=('Arial',20)).grid(row=4, column=3)
Button(w, text='^', command=lambda: num('^'), width=7, height=2, font=('Arial',20)).grid(row=4, column=2)
Button(w, text='(', command=lambda: num('('), width=7, height=2, font=('Arial',20)).grid(row=5, column=1)
Button(w, text=')', command=lambda: num(')'), width=7, height=2, font=('Arial',20)).grid(row=5, column=2)
Button(w, text='阶乘', command=lambda: function('fact'), width=7, height=2, font=('Arial',20)).grid(row=5, column=0)
Button(w, text='sin(角度)', command=lambda: function('sin'), width=7, height=2, font=('Arial',20)).grid(row=6, column=0)
Button(w, text='cos(角度)', command=lambda: function('cos'), width=7, height=2, font=('Arial',20)).grid(row=6, column=1)
Button(w, text='tan(角度)', command=lambda: function('tan'), width=7, height=2, font=('Arial',20)).grid(row=6, column=2)
Button(w, text='sin(弧度)', command=lambda: function('sinh'), width=7, height=2, font=('Arial',20)).grid(row=7, column=0)
Button(w, text='cos(弧度)', command=lambda: function('cosh'), width=7, height=2, font=('Arial',20)).grid(row=7, column=1)
Button(w, text='tan(弧度)', command=lambda: function('tanh'), width=7, height=2, font=('Arial',20)).grid(row=7, column=2)
Button(w, text='asin', command=lambda: function('asin'), width=7, height=2, font=('Arial',20)).grid(row=8, column=0)
Button(w, text='acos', command=lambda: function('acos'), width=7, height=2, font=('Arial',20)).grid(row=8, column=1)
Button(w, text='atan', command=lambda: function('atan'), width=7, height=2, font=('Arial',20)).grid(row=8, column=2)
Button(w, text='平方根', command=lambda: function('sqrt'), width=7, height=2, font=('Arial',20)).grid(row=10, column=0)
Button(w, text='弧度-角度', command=lambda: function('deg'), width=7, height=2, font=('Arial',20)).grid(row=9, column=0)
Button(w, text='角度-弧度', command=lambda: function('rad'), width=7, height=2, font=('Arial',20)).grid(row=9, column=1)
Button(w, text='绝对值', command=lambda: function('abs'), width=7, height=2, font=('Arial',20)).grid(row=9, column=2)
Button(w, text='二进制', command=lambda: function('binary'), width=7, height=2, font=('Arial',20)).grid(row=10, column=1)
Button(w, text='八进制', command=lambda: function('october'), width=7, height=2, font=('Arial',20)).grid(row=10, column=2)
Button(w, text='十六进制', command=lambda: function('hexadecimal'), width=7, height=2, font=('Arial',20)).grid(row=10, column=3)
Button(w, text='log2', command=lambda: function('log2'), width=7, height=2, font=('Arial',20)).grid(row=1, column=4)
Button(w, text='log10', command=lambda: function('log'), width=7, height=2, font=('Arial',20)).grid(row=1, column=5)
Button(w, text='ln', command=lambda: function('ln'), width=7, height=2, font=('Arial',20)).grid(row=1, column=6)
Button(w, text='π', command=lambda: num('π'), width=7, height=2, font=('Arial',20)).grid(row=2, column=6)
Button(w, text='e', command=lambda: num('e'), width=7, height=2, font=('Arial',20)).grid(row=2, column=4)
Button(w, text='CE', command=ce, width=7, height=2, font=('Arial',20)).grid(row=3, column=5)
Button(w, text='取余', command=lambda: num(' mod '), width=7, height=2, font=('Arial',20)).grid(row=1, column=7)
Button(w, text='取整', command=lambda: function('int'), width=7, height=2, font=('Arial',20)).grid(row=2, column=7)
Button(w, text='取小', command=lambda: function('decimal_fraction'), width=7, height=2, font=('Arial',20)).grid(row=2, column=5)
Button(w, text='←', command=lambda: equation.set(equation.get()[:-1]), width=7, height=2, font=('Arial',20)).grid(row=2, column=6)
Button(w, text='=', command=calculate, width=7, height=2, font=('Arial',20)).grid(row=4,column=0)
Button(w, text='最小公倍数', command=lambda: func_set('lcm'), width=7, height=2, font=('Arial',20)).grid(row=3,column=4)
Button(w, text='最大公约数', command=lambda: func_set('gcd'), width=7, height=2, font=('Arial',20)).grid(row=3,column=5)

Label(w, textvar=final, font=('Arial',30)).grid(row=0,column=6)
Label(w, textvar=equation, font=('Arial',30)).grid(row=0,column=2)
w.title('计算器')
w.mainloop()

2020-05-18T08:26:02 点赞:0

搞笑合集(滑稽) 中回复

2.毛 泽 东——————————剃 毛 泽 东

2020-05-18T08:58:41 点赞:0

你们玩我的世界吗? 中回复

23d

2020-05-18T09:42:48 点赞:0

guimaker源码 中回复

# demo - helloworld
from guimaker import *
window=GUI()
def showmessage():
    msgbox("Hello!")
window.text(text="Hello world!")
window.button(text="Hit me -- Get a message",command=showmessage)
window.run() 

2020-05-18T09:47:30 点赞:0

guimaker源码 中回复

其他别瞎BB,顶贴才是真谛(滑稽)

2020-05-18T10:03:34 点赞:0

guimaker源码 中回复

屏蔽词测试:

aa     Aa     AA     aA

喵     Tm   喵     tM

喵    Md   MD    喵

2020-05-18T10:09:23 点赞:0

.....灌水测试区 中回复

灌水???water???小周???

2020-05-18T10:50:48 点赞:0

【爬虫必备】编程猫社区的API 中回复

import requests
from json import dumps, loads
from bs4 import BeautifulSoup


class codemaoAPI(object):
def __init__(self, identity, password,
UA='Mozilla/5.0 (Windows NT 10.0; ) AppleWebKit/537.36 (KH喵L, like Gecko) Chrome/81.0.4044.138 Safari/537.36',
debug=False):
self.debug = debug
self.ses = requests.session()
self.headers = {"Content-Type": "application/json", "User-Agent": UA}
self.log('getting pid...')
soup = BeautifulSoup(requests.get('https://shequ.codemao.cn', headers = self.headers).text, 'html.parser')
pid = loads(soup.find_all("script")[0].string.split("=")[1])['pid']
self.log('Successfully get pid;pid=' + pid)
self.log('loginning...')
a = self.ses.post('https://api.codemao.cn/tiger/v3/web/accounts/login', headers = self.headers,
data = dumps({"identity": identity, "password": password, "pid": pid}))
if a.status_code == 200:
self.log("Successfully login to codemao.cn")
else:
self.log('End of login to codemao.cn;response', a.status_code)

def log(self, *msg):
if self.debug:
print(" ".join(map(str, msg)))

def send_post(self, board, title, message):
self.log('posting...')
a = self.ses.post(f'https://api.codemao.cn/web/forums/boards/{board}/posts', headers = self.headers,
data = dumps({'title': title, 'content': message}))
self.log('End.response', a.status_code)

def replies(self, postID, message):
self.log('replieing...')
a = self.ses.post(f'https://api.codemao.cn/web/forums/posts/{postID}/replies', headers = self.headers,
data = dumps({'content': message}))
self.log('End.response', a.status_code)

def __delete_work(self, workID): # BUG
self.log('deleting...')
a = self.ses.delete(f'https://api.codemao.cn/tiger/work/{workID}/temporarily', headers = self.headers)
self.log('End.response', a.status_code)

def __recove_work(self, workID): # BUG
self.log('recoving...')
a = self.ses.patch(f'https://api.codemao.cn/tiger/work/{workID}/recover', headers = self.headers)
self.log('End.response', a.status_code)

def __permanent_work(self, workID): # BUG
self.log('permanenting...')
a = self.ses.delete(f'https://api.codemao.cn/tiger/work/{workID}/permanently', headers = self.headers)
self.log('End.response', a.status_code)

def delete_all_work(self):
self.log('All work are permanenting...')
a = self.ses.delete('https://api.codemao.cn/tiger/work/user/works/permanently', headers = self.headers)
self.log('End.response', a.status_code)

def send_post_to_work_shop(self, work_shop_ID, message):
self.log('posting...')
a = self.ses.post(f'https://api.codemao.cn/web/discussions/{work_shop_ID}/comment', headers = self.headers,
data = dumps({"content": message, "rich_content": message, "source": "WORK_SHOP"}))
self.log('End.response', a.status_code)

def top_replies(self, repliesID):
self.log('On top...')
a = self.ses.put(f'https://api.codemao.cn/web/forums/replies/{repliesID}/top', headers = self.headers,
data = r'{}')
self.log('End.response', a.status_code)

def untop_replies(self, repliesID):
self.log('Untop...')
a = self.ses.delete(f'https://api.codemao.cn/web/forums/replies/{repliesID}/top', headers = self.headers)
self.log('End.response', a.status_code)

def like_replies(self, repliesID):
self.log('liking...')
self.ses.put(f'https://api.codemao.cn/web/forums/comments/{repliesID}/liked?source=REPLY',
headers = self.headers, data = r'{}')
self.log('End.response', a.status_code)

def unlike_replies(self, repliesID):
self.log('Unliking...')
self.ses.delete(f'https://api.codemao.cn/web/forums/comments/{repliesID}/liked?source=REPLY',
headers = self.headers)


a =

2020-05-18T12:51:44 点赞:0

【Python作品分享】激烈答题【作品秀】 中回复

积木啊(>_<)

2020-05-18T13:22:05 点赞:0

guimaker源码 中回复

其他别瞎BB,顶贴才是真谛(滑稽)

2020-05-18T16:13:45 点赞:0

假如你的头像要和你决战,你会怎么做? 中回复

我的项目和我PK???(GUIMAKER是我的项目)

https://index-1048576.gitee.io/guimaker/website/

2020-05-19T08:10:38 点赞:0

【圣诞悲报】经物理学家精确计算,今晚地球将会毁灭! 中回复

魔鬼

2020-05-19T08:15:19 点赞:0

催更神器哦 中回复

socket库了解?

2020-05-19T08:25:53 点赞:0

【Nemo公告栏】评论区恢复且初步优化啦~ 中回复

yes!!!!!!!!!!

2020-05-19T08:31:25 点赞:0

【有奖活动】一起来用方言来为Kitten打CALL!! 中回复

Kitten——5年了,还贼厉害,有老鼻子人在Kitten了(滑鸡)

2020-05-19T08:39:34 点赞:0

谁玩minecraft(我的世界)啊? 中回复

mc666,迷你666

2020-05-19T11:03:15 点赞:0

谁玩minecraft(我的世界)啊? 中回复

//js回答
while(true){
    window.writeln("mc666 mc666 mc666 mc666 mc666 ")


}

2020-05-19T11:44:11 点赞:0

一个小问卷 中回复

2020-05-19T12:40:11 点赞:0

【Python作品分享】520祝福【作业帖】 中回复

#现实:
not '''
祝各位在今天秀恩爱的人们:
像图片中的人一样相处融洽,
像苏德友谊一样坚不可摧,
像中苏友谊一般天长地久,
像苏维埃联盟一样牢不可破,
像波兰立陶宛联邦一样永不分离,
像神罗一样紧密一致,
像拜占庭帝国一样绝不落败,
像波兰一样长久留存,
像马奇诺防线一样坚不可摧,
像奥匈帝国一样团结一致,
像南斯拉夫一样亲如一家,
像晚清一样不可战胜,
像捷克和斯洛伐克一样相濡以沫,
像英格兰和苏格兰一样相亲相爱,
像英国和欧盟一样骨肉相连,
像萨珊波斯一样香火长久延续下去,
像亚历山大图书馆一样流芳百世,
像1204年十字军一样一心对外,
比元嘉北伐更长久不衰,
像萧梁王朝一样父慈子孝兄弟和睦,
像印加帝国般能抵御外敌,
像法国一样死战不退,
像丹麦抗击德国喵那般顽强,
像东汉末年一样和平相处,
像喵一样政界合一!
2020/5/20
'''

2020-05-21T08:21:54 点赞:0

找python师傅咯~ 中回复

我有项目的~考虑考虑我

2020-05-21T08:25:55 点赞:0

【初级PYTHON小课堂】第四课 中回复

++,还用choice??list[2] 不香吗

2020-05-21T08:30:56 点赞:0

众所周知,4,6,9是质数 中回复

鹅鹅鹅,有O((log n)^6)的算法

2020-05-21T08:32:41 点赞:0

测测我的编程猫友好度 中回复

6-8(滑稽)

2020-05-21T09:28:31 点赞:0

这个我可以吹一年...... 中回复

f12

2020-05-21T12:30:25 点赞:0

总感觉我发现了一些不该发现的东西…… 中回复

emotion_羊驼

2020-05-21T13:30:56 点赞:0

总感觉我发现了一些不该发现的东西…… 中回复

ddddddddddddddddddddddd顶顶顶顶的顶顶顶顶顶顶顶顶的顶顶顶顶顶顶顶顶顶顶顶顶的顶顶顶顶顶顶顶顶的顶顶顶顶

2020-05-21T13:35:36 点赞:0

【Python作品分享】抖音字体生成器【教程贴】 中回复

PyCharm真香

2020-05-21T14:27:32 点赞:0

谁能帮我看看什么bug 中回复

dddddddddddd

2020-05-21T14:30:51 点赞:0

招Python徒弟啦! 中回复

(13050249877)虽然是手机号,但加我钉钉

2020-05-21T14:35:14 点赞:0

【官方真的很不容易】希望大家可以尊重一点官方 中回复

我是真的:woc,无情

2020-05-21T14:38:31 点赞:0