【问题标题】:"Save As" wizard for CSV file in PythonPython中CSV文件的“另存为”向导
【发布时间】:2012-07-26 06:53:03
【问题描述】:

我可以使用以下代码保存 Excel 文件:

f = cStringIO.StringIO()  # This is a buffer to Store the above values
wb.save(f)  # This will save the buffer
output_data=base64.encodestring(f.getvalue()) 
res = self.write(cr, uid, ids, {'state':'get','data':output_data, 'name':'kpi.xls'}, context=context)
return res 

但我无法使用另存为向导保存 CSV 文件。

【问题讨论】:

  • 我只想将文件保存在系统中的任何特定位置。就像下载向导一样。
  • 您的代码不完整。貌似是某个类的一部分,但你粘贴的方法也不完整。

标签: python excel csv python-2.7


【解决方案1】:

代码和解释不完整,但据我了解,您需要一个“另存为”对话框。 tkFileDialog in Tkinter 应该可以解决问题。

 filename = tkFileDialog.asksaveasfilename()
res = self.write(cr, uid, ids, {'state':'get','data':output_data, 'name':filename}, context=context)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-16
    • 2014-03-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多