久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <i id='qXyk0'><tr id='qXyk0'><dt id='qXyk0'><q id='qXyk0'><span id='qXyk0'><b id='qXyk0'><form id='qXyk0'><ins id='qXyk0'></ins><ul id='qXyk0'></ul><sub id='qXyk0'></sub></form><legend id='qXyk0'></legend><bdo id='qXyk0'><pre id='qXyk0'><center id='qXyk0'></center></pre></bdo></b><th id='qXyk0'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='qXyk0'><tfoot id='qXyk0'></tfoot><dl id='qXyk0'><fieldset id='qXyk0'></fieldset></dl></div>
  • <legend id='qXyk0'><style id='qXyk0'><dir id='qXyk0'><q id='qXyk0'></q></dir></style></legend>
    <tfoot id='qXyk0'></tfoot>
    • <bdo id='qXyk0'></bdo><ul id='qXyk0'></ul>

      <small id='qXyk0'></small><noframes id='qXyk0'>

        如何使用 asksaveasfile 將文本從 Text-widget Tkinter 保

        How to save text from a Text-widget Tkinter to a .doc using asksaveasfile?(如何使用 asksaveasfile 將文本從 Text-widget Tkinter 保存到 .doc?)

        <small id='W7hbf'></small><noframes id='W7hbf'>

              <tbody id='W7hbf'></tbody>

              <legend id='W7hbf'><style id='W7hbf'><dir id='W7hbf'><q id='W7hbf'></q></dir></style></legend>
                <bdo id='W7hbf'></bdo><ul id='W7hbf'></ul>
                  <i id='W7hbf'><tr id='W7hbf'><dt id='W7hbf'><q id='W7hbf'><span id='W7hbf'><b id='W7hbf'><form id='W7hbf'><ins id='W7hbf'></ins><ul id='W7hbf'></ul><sub id='W7hbf'></sub></form><legend id='W7hbf'></legend><bdo id='W7hbf'><pre id='W7hbf'><center id='W7hbf'></center></pre></bdo></b><th id='W7hbf'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='W7hbf'><tfoot id='W7hbf'></tfoot><dl id='W7hbf'><fieldset id='W7hbf'></fieldset></dl></div>

                  <tfoot id='W7hbf'></tfoot>

                • 本文介紹了如何使用 asksaveasfile 將文本從 Text-widget Tkinter 保存到 .doc?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我想使用 asksaveasfilename 對話框將我在 Text 小部件中輸入的一些內容保存為 .txt.doc 格式.在此之后,我希望它分別打開.記事本或 MS Word.

                  I want to save some stuff I entered in a Text widget to a .txt or .doc format, using an asksaveasfilename dialog box. After this I want it to open in resp. Notepad or MS Word.

                  from tkFileDialog import asksaveasfilename
                  import os.path
                  
                  name = asksaveasfilename(
                             initialdir="dir",
                             title="Save as",
                             filetypes=[("Text files",".txt"),("Word files",".doc")])
                  
                  data = open(name,"w")
                  data.write("text from text widget")
                  
                  os.startfile(name)
                  

                  它會創建文件,但不會在 MS Word 或記事本中打開它.相反,它詢問我想如何打開這個文件.如果我選擇程序,它將正確打開,但我希望它直接打開.(不選擇打開文件的程序).當我直接在文件名:"框中提供擴展名時,它會按照我想要的方式工作.

                  It creates the file but it won't open it in MS Word or Notepad. Instead it asks how I want to open this file. If I choose the programm it will open correctly, but I want it to open directly. (without choosing a program to open the file with). When I give the extension directly in the "File name:" box it works the way I want though.

                  這有效:文件名:something.doc保存類型:Word 文件 (*.doc)---> 創建 something.doc 并在 MS Word 中打開它.

                  This works: File name: something.doc Save as type: Word file (*.doc) ---> creates something.doc and opens it in MS Word.

                  但這并不文件名稱:某事保存類型:Word 文件 (*.doc)---> 創建一些東西(沒有擴展名)并詢問我希望它在什么程序中打開.

                  But this doesn't File name: something Save as type: Word file (*.doc) ---> creates something (no extension) and ask in what program I want it to open.

                  我使用 Python 2.7.8、Windows 8、Office 2010.

                  I use Python 2.7.8, Windows 8, Office 2010.

                  推薦答案

                  加上print name就可以看到問題,例如

                  You can see the problem if you add print name, e.g.

                  C:/Users/jsharpe/Downloads/testing
                  

                  請注意,沒有添加任何擴展 - 我只輸入了 "testing".filetypes 參數對于限制用戶選擇現有文件更有用,如果用戶不提供擴展名,它將不會添加適當的擴展名.

                  note that no extension has been added - I only entered "testing". The filetypes argument is more useful for limiting the user's selection of existing files, it won't add the appropriate extension if the user doesn't supply one.

                  您可以為用戶不輸入擴展名的情況設置 defaultextension,但這不會反映在下拉列表中選擇的類型(例如,如果您設置了 defaultextension=".txt" 即使用戶從 filetypes 中選擇該選項,它也不會是 .doc).

                  You can set a defaultextension for the cases where the user doesn't enter an extension, but this won't reflect the type selected in the drop-down (e.g. if you set defaultextension=".txt" it won't be .doc even if the user chooses that option from filetypes).

                  name = asksaveasfilename(defaultextension=".txt",
                                           filetypes=[("Text files",".txt"),
                                                      ("Word files",".doc")],
                                           initialdir="dir",
                                           title="Save as")
                  

                  (請注意,隨著您添加越來越多的選項,按字母順序排列的參數順序會讓生活變得更輕松)

                  附帶說明,您(仍然!)不要 close 文件,這可能會導致問題 - 我建議對文件使用 with 上下文管理器處理:

                  On a side note, you (still!) don't close the file, which could cause issues - I'd suggest using the with context manager for file handling:

                  with open(name, "w") as data:
                      data.write("text from text widget")
                  

                  這篇關于如何使用 asksaveasfile 將文本從 Text-widget Tkinter 保存到 .doc?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                  Discord bot isn#39;t responding to commands(Discord 機器人沒有響應命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關于我嗎?Discord 機器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)
                • <legend id='JJYtX'><style id='JJYtX'><dir id='JJYtX'><q id='JJYtX'></q></dir></style></legend>

                  1. <i id='JJYtX'><tr id='JJYtX'><dt id='JJYtX'><q id='JJYtX'><span id='JJYtX'><b id='JJYtX'><form id='JJYtX'><ins id='JJYtX'></ins><ul id='JJYtX'></ul><sub id='JJYtX'></sub></form><legend id='JJYtX'></legend><bdo id='JJYtX'><pre id='JJYtX'><center id='JJYtX'></center></pre></bdo></b><th id='JJYtX'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='JJYtX'><tfoot id='JJYtX'></tfoot><dl id='JJYtX'><fieldset id='JJYtX'></fieldset></dl></div>

                      <tfoot id='JJYtX'></tfoot>
                            <bdo id='JJYtX'></bdo><ul id='JJYtX'></ul>

                            <small id='JJYtX'></small><noframes id='JJYtX'>

                              <tbody id='JJYtX'></tbody>
                            主站蜘蛛池模板: 免费一区 | 美女国产精品 | 一级在线视频 | 国产分类视频 | 欧州一区二区三区 | 欧美成人a∨高清免费观看 老司机午夜性大片 | 日韩中文字幕 | 蜜桃视频在线观看www社区 | 伊人狠狠干 | 国产成人免费视频网站视频社区 | www免费视频 | 丝袜一区二区三区 | 51ⅴ精品国产91久久久久久 | 我要看免费一级毛片 | 午夜合集 | 伊人91在线 | 国产精品美女久久久久aⅴ国产馆 | 欧美专区在线 | 欧美精品影院 | 欧美一区二区三区视频 | 狠狠色综合欧美激情 | 综合一区二区三区 | 亚洲国产免费 | 亚洲免费高清 | 日韩成人在线视频 | 91精品国产91综合久久蜜臀 | 日韩精品久久久久 | 在线国产一区二区 | 国产精品18久久久 | 国产欧美日韩久久久 | 精品久久久久久18免费网站 | 国产激情一区二区三区 | 特黄色一级毛片 | 亚洲免费网 | h视频在线免费 | 国产视频福利一区 | 国产亚洲日本精品 | 国产精品一区三区 | 一级片在线观看 | 久久久久国产一区二区三区 | 久久99精品久久久久婷婷 |