会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132947个问题
JAVA 全系列/第十八阶段:亿级高并发电商项目_架构/编码(旧)/电商:使用Nginx实现负载均衡及整体环境部署 21616楼
人工智能/第六阶段:机器学习-线性分类/逻辑回归 21617楼
Python 全系列/第七阶段:网页编程基础/CSS 样式 21619楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/多线程技术(旧) 21620楼

老师,请问,保存之后,为什么在文件夹中找不到这个文件呢

image.png

#coding=utf-8
'''开发记事本软件'''
from tkinter.filedialog import *
from tkinter.colorchooser import *

class Application(Frame):
    def __init__(self,master=None):
        super().__init__(master)
        self.master=master
        self.textpad=None
        self.filename=None
        self.contextMenu=None
        self.pack()
        self.createWidget()

    def createWidget(self):
        # 创建主菜单栏
        menubar=Menu(root)
        # 创建子菜单
        menuFile=Menu(menubar)
        menuEdit=Menu(menubar)
        menuHelp=Menu(menubar)

        # 将子菜单加入主菜单栏
        menubar.add_cascade(label="文件",menu=menuFile)
        menubar.add_cascade(label="编辑",menu=menuEdit)
        menubar.add_cascade(label="帮助",menu=menuHelp)

        #添加菜单项
        menuFile.add_command(label="新建",accelerator="ctrl+n",command=self.newfile)
        menuFile.add_command(label="打开",accelerator="ctrl+o",command=self.openfile)
        menuFile.add_command(label="保存", accelerator="ctrl+s", command=self.savefile)
        menuFile.add_separator()        #添加分割线
        menuFile.add_command(label="退出", accelerator="ctrl+q", command=self.exit)

        root["menu"]=menubar
        # 文本编辑区
        self.textpad = Text(root, width=50, height=30)
        self.textpad.pack()

        # 创建上下级菜单
        self.contextMenu=Menu(root)
        self.contextMenu.add_command(label="背景颜色",command=self.openAskColor)

        root.bind("<Button-3>",self.createContextMenu)

        # 添加快捷键事件处理
        root.bind("<Control-n>",lambda event:self.newfile())
        root.bind("<Control-o>",lambda event:self.openfile())
        root.bind("<Control-s>",lambda event:self.savefile())
        root.bind("<Control-q>",lambda event:self.exit())
    def createContextMenu(self,event):
        self.contextMenu.post(event.x_root,event.y_root)
    def openAskColor(self):
        s1=askcolor(color="red",title="选择背景色")

        self.textpad.config(bg=s1[1])
        print(s1)

    def newfile(self):
        self.filename=asksaveasfilename(title="另存为",initialfile="未命名.txt",
                                        filetypes=[("文本文档","*.txt")],
                                        defaultextension=".txt")
        print(self.filename)
    def openfile(self):
        with askopenfile(title="打开文件") as f:
            self.textpad.insert(INSERT,f.read())
            self.filename=f.name
            print(f.name)
            self.savefile()
    def savefile(self):
        with open(self.filename,"w") as f:
            c=self.textpad.get(1.0,END)
            f.write(c)
    def exit(self):
        root.quit()



if __name__=="__main__":
    root=Tk()
    root.geometry("450x300+200+300")
    root.title("百战程序员的简易记事本")
    app=Application(master=root)
    root.mainloop()


Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 21621楼
JAVA 全系列/第四阶段:网页编程和设计/HTML5(旧) 21623楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/网络编程(旧) 21624楼
JAVA 全系列/第四阶段:网页编程和设计/Javascript 语言(旧) 21625楼

MySQL的安装问题。

win10系统,64位,安装5.7.36版本。

再下面这幅图的一步卡住啦。(自己百度网上各种方式,还是会这样)。

image.png

log里的内容如下:

Saving my.ini configuration file...

Saved my.ini configuration file.

Ended configuration step: Writing configuration file


Beginning configuration step: Updating Windows Firewall rules


Adding a Windows Firewall rule for MySQL57 on port 3306.

Attempting to add a Windows Firewall rule with command: netsh.exe advfirewall firewall add rule name="Port 3306" protocol=TCP localport=3306 dir=in action=allow

确定。



Successfully added the Windows Firewall rule.

Ended configuration step: Updating Windows Firewall rules


Beginning configuration step: Adjusting Windows service


Attempting to grant Network Service require filesystem permissions.

Granted permissions.

Adding new service

New service added

Ended configuration step: Adjusting Windows service


Beginning configuration step: Initializing database (may take a long time)


Deleting the data directory from a previous (failed) configuration...

Attempting to run MySQL Server with --initialize-insecure option...

Starting process for MySQL Server 5.7.36...

Starting process with command: C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.7\my.ini" --console --initialize-insecure=on --lower-case-table-names=1...

2022-05-26T07:06:52.121753Z 0 [ERROR] Invalid value for named_pipe_full_access_group.

2022-05-26T07:06:52.121817Z 0 [ERROR] Aborting

Process for mysqld, with ID 12228, was run successfully and exited with code 1.

Failed to start process for MySQL Server 5.7.36.

Database initialization failed.

Ended configuration step: Initializing database (may take a long time)


JAVA 全系列/第三阶段:数据库编程/MySQL数据库 21626楼
JAVA 全系列/第三阶段:数据库编程/SQL 语言 21627楼
JAVA 全系列/第九阶段:权限控制与安全认证/Shiro 21630楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637