如何让Windows自动添加扩展名到文件?
发布时间:2020-12-14 05:25:14 所属栏目:Windows 来源:网络整理
导读:背景 我目前正在制作一个基本的文本编辑器,希望能够对Tkinter有一个基本的了解.我想创建自己的文件格式.mydoc我试图将文件类型更改为.mydoc为无.这是我目前拥有的代码: 码 def openMe(self): #import the Tk file dialogue import tkFileDialog as tkF myFo
背景
我目前正在制作一个基本的文本编辑器,希望能够对Tkinter有一个基本的了解.我想创建自己的文件格式.mydoc我试图将文件类型更改为.mydoc为无.这是我目前拥有的代码: 码 def openMe(self): #import the Tk file dialogue import tkFileDialog as tkF myFormat = [('Example Format','*.mydoc')] direct = tkF.askopenfilename(initialdir='D:',filetypes = myFormat,title = "Open a .mydoc") try: #open the text file txt_file = open(direct,"r") except UnboundLocalError,IOError: print "You either did not select a file,or the filetype was incorrect.nPlease try again." #Read the data currentTEXT = txt_file.read() #Delete current text self.write.delete(0.0,END) #insert new text self.write.insert(0.0,currentTEXT) 题 >如何让计算机自动添加我的分机? (是的,我已经关闭了隐藏扩展选项. 技术规格 语言:Python 2.7.3 操作系统:Windows 7 解决方法
尝试使用defaultextension:
tkF.askopenfilename(initialdir='D:',filetypes=myFormat,title="Open a .mydoc",defaultextension=".mydoc") (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows – 是否有针对Microsoft堆栈的推荐自动化生产环境设
- 命令行 – 在Windows 2008 Server中从MP3 / WAV文件生成可视
- Windows 2008 Server SP2 64位 – 在TIME_WAIT之后,TCP连接
- 将Uint8Array转换为JavaScript中的数组
- windows-server-2008 – Windows搜索不搜索文件
- windows – 任何人都知道一个好的自包含嗅探器?
- WindowsPE权威指南-PE文件头中的重定位表
- Windows – Active Directory GPO中的SID
- crystal-reports – 如何从CAB文件创建MSI?
- windows – SAPI:Speech to Text示例
推荐文章
站长推荐
热点阅读