Lv.1
在 【❗️注意】未通过代码岛3.0编辑器申请的进 中回复
支持JavaScript!!!
支持JavaScript!!!
支持JavaScript!!!
支持JavaScript!!!
支持JavaScript!!!
alert('支持JavaScript!!!');2020-03-30T09:26:44 点赞:3
在 【Python作品分享】cmd 中回复
我发现一段代码可以无缝调用命令行,
import os
a = 'c'+'m'+'d' #本来不用怎么麻烦,但怕屏蔽。
os.system('%s.exe' % a)
像真的命令提示符。
2020-03-30T10:04:29 点赞:1
在 【建议】关于屏蔽字c m d和h t m l 中回复
各位,我发现一个帖子名的被屏蔽的帖子。
https://shequ.codemao.cn/community/246721
2020-03-30T10:39:47 点赞:1
在 【Python作品分享】文件保存器【教程贴】 中回复
from os import getlogin
text = input("请输入内容:")
with open("C:\\Users\\%s\\Desktop\\文件.txt"%getlogin(),'w') as f:
f.write(text)
print('完成')
用户桌面在 :\Users\<登录的用户名>\Desktop
2020-04-20T15:21:00 点赞:0
在 【Python作品分享】一个极其普通的计算器1.10【作品秀】 中回复
import tkinter as tk #导入tkinter模块
import math as m
#创建一个跟窗口
root = tk.Tk()
root.minsize(280,470)
root.title('计算器')
#1.界面布局
#显示面板
result1 = tk.StringVar()
result1.set(0) #显示面板显示结果1,用于显示默认数字0
result2 = tk.StringVar() #显示面板显示结果2,用于显示计算过程
result2.set('')
#显示屏幕
screen2 = tk.Label(root,font = ('微软雅黑',20),bg = '#EEE9E9',bd ='9',fg = 'black',textvariable=result1,anchor='se')
screen2.place(width = 280,height = 170)
screen1 = tk.Label(root,font = ('微软雅黑',30),bg = '#EEE9E9',bd ='9',fg = 'black',textvariable=result2,anchor='se')
screen1.place(width = 280,height = 110)
#从上往下第一行
buttonmod = tk.Button(root,font = ('微软雅黑',20),text='%',bd ='0.5',fg = 'black',command=lambda : pressfunction('//'))
buttonmod.place(x=0,y=170,width=70,height=50)
buttonsqrt = tk.Button(root,font = ('微软雅黑',20),text='√',bd ='0.5',fg = 'black',command=lambda : pressfunction('√'))
buttonsqrt.place(x=70,y=170,width=70,height=50)
buttonpower = tk.Button(root,font = ('微软雅黑',20),text='x²',bd ='0.5',fg = 'black',command=lambda : pressfunction('x²'))
buttonpower.place(x=140,y=170,width=70,height=50)
buttondowncount = tk.Button(root,font=('微软雅黑',20),text='1/x',bd='0.5',fg = 'black',command=lambda : pressfunction('1/x'))
buttondowncount.place(x=210,y=170,width=70,height=50)
#第二行
buttonce = tk.Button(root,font=('微软雅黑',20),text='CE',bg='orange',bd='0.5',fg='black',command=lambda : pressfunction('CE'))
buttonce.place(x=0,y=220,width=70,height=50)
buttonc = tk.Button(root,font=('微软雅黑',20),text='C',bd='0.5',fg='black',command=lambda : pressfunction('C'))
buttonc.place(x=70,y=220,width=70,height=50)
buttondelete = tk.Button(root,font=('微软雅黑',20),text='←',bd='0.5',fg='black',command=lambda : pressfunction('←'))
buttondelete.place(x=140,y=220,width=70,height=50)
buttondiv = tk.Button(root,font=('微软雅黑',20),text='÷',bd='0.5',fg='black',command=lambda : pressfunction('/'))
buttondiv.place(x=210,y=220,width=70,height=50)
#第三行
button7 = tk.Button(root,font=('微软雅黑',20),text='7',bd='0.5',bg='white',command= lambda : pressnumber('7'))
button7.place(x=0,y=270,width=70,height=50)
button8 = tk.Button(root,font=('微软雅黑',20),text='8',bd='0.5',bg='white',command=lambda : pressnumber('8'))
button8.place(x=70,y=270,width=70,height=50)
button9 = tk.Button(root,font=('微软雅黑',20),text='9',bd='0.5',bg='white',command=lambda : pressnumber('9'))
button9.place(x=140,y=270,width=70,height=50)
buttonmul = tk.Button(root,font=('微软雅黑',20),text='×',bd='0.5',fg='black',command=lambda : pressfunction('*'))
buttonmul.place(x=210,y=270,width=70,height=50)
#第四行
button4 = tk.Button(root,font=('微软雅黑',20),text='4',bd='0.5',bg='white',command=lambda : pressnumber('4'))
button4.place(x=0,y=320,width=70,height=50)
button5 = tk.Button(root,font=('微软雅黑',20),text='5',bd='0.5',bg='white',command=lambda : pressnumber('5'))
button5.place(x=70,y=320,width=70,height=50)
button6 = tk.Button(root,font=("微软雅黑",20),text='6',bd='0.5',bg='white',command=lambda : pressnumber('6'))
button6.place(x=140,y=320,width=70,height=50)
buttonsub = tk.Button(root,font=('微软雅黑',20),text='-',bd='0.5',fg='black',command=lambda : pressfunction('-'))
buttonsub.place(x=210,y=320,width=70,height=50)
#第五行
button1 = tk.Button(root,font=('微软雅黑',20),text='1',bd='0.5',bg='white',command=lambda : pressnumber('1'))
button1.place(x=0,y=370,width=70,height=50)
button2 = tk.Button(root,font=('微软雅黑',20),text='2',bd='0.5',bg='white',command=lambda : pressnumber('2'))
button2.place(x=70,y=370,width=70,height=50)
button3 = tk.Button(root,font=("微软雅黑",20),text='3',bd='0.5',bg='white',command=lambda : pressnumber('3'))
button3.place(x=140,y=370,width=70,height=50)
buttonadd = tk.Button(root,font=('微软雅黑',20),text='+',bd='0.5',fg='black',command=lambda : pressfunction('+'))
buttonadd.place(x=210,y=370,width=70,height=50)
#第六行
buttoninverse = tk.Button(root,font=("微软雅黑",20),text='±',bd='0.5',fg='black',command=lambda : pressfunction('±'))
buttoninverse.place(x=0,y=420,width=70,height=50)
button0 = tk.Button(root,font=("微软雅黑",20),text='0',bd='0.5',bg='white',command=lambda : pressnumber('0'))
button0.place(x=70,y=420,width=70,height=50)
buttonpoint = tk.Button(root,font=("微软雅黑",20),text='.',bd='0.5',fg='black',command=lambda : pressnumber('.'))
buttonpoint.place(x=140,y=420,width=70,height=50)
buttonvalue = tk.Button(root,font=("微软雅黑",20),text='=',bd='0.5',bg='orange',fg='black',command=lambda : pressequal())
buttonvalue.place(x=210,y=420,width=70,height=50)
#操作函数
lists = [] #设置一个变量 保存运算数字和符号的列表
ispressfunction = False #添加一个判断是否按下运算符号的标志,假设默认没有按下按钮
ispressnumber = False
ispressequal = False
#数字函数 判断是否按下数字 并获取数字将数字写在显示版上
def pressnumber(num):
global lists #全局化lists
global ispressfunction #按钮状态ispressfunction
global ispressequal #全局化等号状态ispressfunction
if ispressequal == False : #计算完一个结果后 重新输入数据
pass
else :
ispressequal = False #重新将等号设置为0
result1.set('')
if ispressfunction == False:
pass
else: #重新将运算符号状态设置为0
result1.set(0)
ispressfunction = False
oldnum = result1.get() #第一步判断界面的数字是否为0
if oldnum =='0': #如过界面上数字为0 则获取按下的数字
result1.set(num)
else: #如果界面上的而数字不是0 则链接上新按下的数字
newnum = oldnum + num
result1.set(newnum) #将按下的数字写到面板中
#按功能键函数 判断是否按下功能键
def pressfunction(stringlist):
global lists
global ispressfunction
global ispressequal
num = result1.get() #获取界面数字
lists.append(num) #将界面上的数字添加到lists列表中
shizi = '' #设置一个字符串将每次点击功能键后的式子显示到屏幕2上
ispressfunction = True
if stringlist in ['-','+','/','*','//']: #如果是常规运算符 加、减、乘、除、取余 那么直接将lists存入列表中
lists.append(stringlist) #将按下的运算符号保存到列表中
for each in lists :
shizi += each
if stringlist not in ['C','CE','←','±']: #如果按的不是这些特殊按键则将按键加入式子 之后显示在label2框中
result2.set(shizi)
if stringlist in ['√','x²','1/x']: #如果按的是开根号,平方根,倒数
if stringlist == '√': #如果取的数开根号
list1 = []
numnow = result1.get() #获取点击根号前 屏幕上的数字
list1.append("sqrt(" + numnow + ")") #将要在屏幕上输出的式子形式加入lists1中
sqrt1 = m.sqrt(int(numnow)) #用math模块计算结果
result2.set(list1) #将式子显示在label2中
result1.set(sqrt1) #将结果显示在lists2中
elif stringlist == 'x²': #获取点击平方前 屏幕上的数字 之后类似
list1 = []
numnow = result1.get()
list1.append("power(" + numnow + ",2)")
power1 = m.pow(int(numnow),2)
result2.set(list1)
result1.set(power1)
else:
list1 = []
numnow = result1.get()
list1.append("1/" + numnow)
countback1 = 1/int(numnow)
result2.set(list1)
result1.set(countback1)
if stringlist =='C': #如果按下的是'C'按键,则清空当前输入的数字,将其设为0
lists.pop() #以及之前存留在列表中的数
result1.set(0)
ispressfunction = False #添加一个判断是否按下运算符号的标志,假设默认没有按下按钮
ispressnumber = False
ispressequal = False
if stringlist =='CE': #如果按下的是'CE'按键,则清空列表内容,讲屏幕上的数字键设置为默认数字0
lists.clear()
result1.set(0)
result2.set('')
if stringlist =='←': #如果按下的是退格‘’,则选取当前数字第一位到倒数第二位
a = num[0:-1]
lists.pop() #将原来lists中添加的未退格的数字去除
result1.set(a)
if stringlist =='±': #如果按下的是取反
lists.pop() #将原来lists中添加的未取反的数字去除
num = str(int(0-int(num)))
result1.set(num)
#获取运算结果函数
def pressequal():
global lists
global ispressfunction
global ispressequal
ispressequal = True #将等号
curnum = result1.get() #设置当前数字变量,并获取添加到列表
lists.append(curnum) #将点下'='时的数字加入列表中
computrStr = ''.join(lists) #讲列表内容用join命令将字符串链接起来
endnum = eval(computrStr) #用eval命令运算字符串中的内容
result1.set(endnum) #讲运算结果显示到屏幕1
result2.set(computrStr) #将运算过程显示到屏幕2
lists.clear() #清空列表内容
root.mainloop()2020-04-20T15:37:45 点赞:1
在 【Python作品分享】base喵打包工具 中回复
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import base64
def setup(filename,by):
with open(filename,"wb") as f:
f.write(base64.b64decode(by))
data = ('base64编解码.py', b'aW1wb3J0IGJhc2U2NA0KaW1wb3J0IG9zDQpmcm9tIHRraW50ZXIuZmlsZWRpYWxvZyBpbXBvcnQgYXNrb3BlbmZpbGVuYW1lDQoNCg0KdGV4dCA9ICIiIiMhL3Vzci9iaW4vZW52IHB5dGhvbjMNCiMgLSotIGNvZGluZzogdXRmLTggLSotDQppbXBvcnQgYmFzZTY0DQoNCmRlZiBzZXR1cChmaWxlbmFtZSxieSk6DQogICAgd2l0aCBvcGVuKGZpbGVuYW1lLCJ3YiIpIGFzIGY6DQogICAgICAgIGYud3JpdGUoYmFzZTY0LmI2NGRlY29kZShieSkpDQpkYXRhID0gIiIiDQoNCmRlZiBkaXN0KCk6DQogICAgaWYgbm90IG9zLnBhdGguZXhpc3RzKCIuXFxkaXN0Iik6DQogICAgICAgIG9zLm1ha2VkaXJzKCIuXFxkaXN0IikgDQoNCg0KDQoNCmRlZiBtYWluKGZpbGUpOg0KICAgIGRpc3QoKQ0KICAgIHdpdGggb3BlbihmaWxlLCJyYiIpIGFzIGY6DQogICAgICAgIGEgP喵iYXNlNjQuYjY0ZW5喵2RlKGYucmVhZCgpKQ0KICAgIHcgP喵yZXByKChvcy5wYXRoLnNwbGl0KGZpbGUpWzFdLGEpKQ0KICAgIGRhdGEgP喵0ZXh0ICsgdyArICdcbnNldHVwKGRhdGFbMF0sZGF0YVsxXSknDQogICAgd2l0aCBvcGVuKCIuXFxkaXN0XFxzZXR1cC5weSIsInciLGVuY29kaW5nPSJ1dGYtOCIpIGFzIGY6DQogICAgICAgIGYud3JpdGUoZGF0YSkNCg0KDQppZiBfX25hbWVfXyA9PSAiX19tYWluX18iOg0KICAgIG1haW4oYXNrb3BlbmZpbGVuYW1lKCkpDQo=')
setup(data[0],data[1])
这就是打包出来的代码。
2020-04-22T16:46:04 点赞:0
在 [教程贴]带你学GUI带你飞——第二章 中回复
课件及源代码下载:https://17097231932.github.io/learn-python-gui
2020-04-24T15:46:28 点赞:0
在 大家快来看看我的作品啊,点赞的最帅啦。 中回复
大佬厉害,你的作品制作肯定用了很多时间,尤其是分数显示,这个在scratch很复杂,一般都是大佬才会做。
2020-05-04T20:48:55 点赞:0
在 【Python作品分享】列表【教程贴】 中回复
列表是可变序列,通常用于存放同类项目的集合(其中精确的相似程度将根据应用而变化)。
list
(
[
iterable
]
)
可以用多种方式构建列表:
使用一对方括号来表示空列表: []
使用方括号,其中的项以逗号分隔: [a], [a, b, c]
使用列表推导式: [x for x in iterable]
使用类型的构造器: list() 或 list(iterable)
构造器将构造一个列表,其中的项与 iterable 中的项具有相同的的值与顺序。 iterable 可以是序列、支持迭代的容器或其它可迭代对象。 如果 iterable 已经是一个列表,将创建并返回其副本,类似于 iterable[:]。 例如,list('abc') 返回 ['a', 'b', 'c'] 而 list( (1, 2, 3) ) 返回 [1, 2, 3]。 如果没有给出参数,构造器将创建一个空列表 []。
其它许多操作也会产生列表,包括 sorted() 内置函数。
2020-05-04T21:10:15 点赞:0