
Lv.1
JUST_nothing小号,欢迎加入JUST_workshop
签名:阿巴阿巴阿巴。。。 学亿点物理和化学,做出完美喵的大统一模型,让我家信息课代(@马蕴杰)设计程序,化学课代(@cyy)执行方案 炸掉学校!!! 阿巴阿巴阿巴。。。
在 #kitten教学第一期 中回复
Python一行不就搞好了:
print('1,2,3,4'.split())#‘1,2,3,4’可替换为任何type==字符串的信息2022-12-24T22:03:01 点赞:0
在 Python逐字输出教程 中回复
'''主文件:'''
import about_file as f
from tkinter import *
import webbrowser as webo
class commands():
def __init__(self):
self.file_name = f.getFileName('main_code_html.html')
def save(self):
with open(self.file_name, 'w') as file:
global codes
file.write(codes.get("1.0", END))
def run(self):
self.save()
webo.open('file://'+self.file_name)
def get(self):
with open(self.file_name, 'r') as file:
code = file.read()
if code == '':
return ''
else:
return code
tk = Tk()
c = commands()
tk.title('Python写的H喵L编译器')
tk.geometry('500x300+200+200')
btn1 = Button(tk, text='保存', command=c.save)
btn1.grid(row=0, column=0)
btn2 = Button(tk, text='运行', command=c.run)
btn2.grid(row=0, column=1)
codes = Text(tk)
codes.place(x=0, y=25)
codes.insert(END, c.get())
tk.mainloop()
import os
import platform
def getFileName(name="record.txt"):
tmp_path = ""
if platform.system() == "Darwin":
tmp_path = os.path.expanduser("~/学而思直播/code/cache/asset_pool")
else:
tmp_path = os.path.expanduser(r"~\学而思直播\code\cache\asset_pool")
whole_path = os.path.join(tmp_path, name)
#初始化
if not os.path.exists(whole_path):
with open(whole_path, "w", encoding="utf-8") as f:
f.write("0")
return whole_path
def openFile(data_path):
if platform.system() == "Windows":
os.startfile(data_path)
elif platform.system() == "Darwin":
subprocess.Popen(["open", data_path])
else:
subprocess.Popen(["xdg-open", data_path])
2022-12-24T22:27:22 点赞:0