
Lv.1
只是喜欢Python而已……徒弟:程序侯
签名:只是喜欢Python而已…… 徒弟:程序侯
在 计算器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
在 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
在 【爬虫必备】编程猫社区的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
在 假如你的头像要和你决战,你会怎么做? 中回复
我的项目和我PK???(GUIMAKER是我的项目)
https://index-1048576.gitee.io/guimaker/website/
2020-05-19T08:10:38 点赞:0
在 谁玩minecraft(我的世界)啊? 中回复
//js回答
while(true){
window.writeln("mc666 mc666 mc666 mc666 mc666 ")
}2020-05-19T11:44:11 点赞:0
在 【Python作品分享】520祝福【作业帖】 中回复
#现实:
not '''
祝各位在今天秀恩爱的人们:
像图片中的人一样相处融洽,
像苏德友谊一样坚不可摧,
像中苏友谊一般天长地久,
像苏维埃联盟一样牢不可破,
像波兰立陶宛联邦一样永不分离,
像神罗一样紧密一致,
像拜占庭帝国一样绝不落败,
像波兰一样长久留存,
像马奇诺防线一样坚不可摧,
像奥匈帝国一样团结一致,
像南斯拉夫一样亲如一家,
像晚清一样不可战胜,
像捷克和斯洛伐克一样相濡以沫,
像英格兰和苏格兰一样相亲相爱,
像英国和欧盟一样骨肉相连,
像萨珊波斯一样香火长久延续下去,
像亚历山大图书馆一样流芳百世,
像1204年十字军一样一心对外,
比元嘉北伐更长久不衰,
像萧梁王朝一样父慈子孝兄弟和睦,
像印加帝国般能抵御外敌,
像法国一样死战不退,
像丹麦抗击德国喵那般顽强,
像东汉末年一样和平相处,
像喵一样政界合一!
2020/5/20
'''2020-05-21T08:21:54 点赞:0
在 总感觉我发现了一些不该发现的东西…… 中回复
ddddddddddddddddddddddd顶顶顶顶的顶顶顶顶顶顶顶顶的顶顶顶顶顶顶顶顶顶顶顶顶的顶顶顶顶顶顶顶顶的顶顶顶顶
2020-05-21T13:35:36 点赞:0