简体   繁体   English

Python中CSV文件的“另存为”向导

[英]“Save As” wizard for CSV file in Python

I am able to save an Excel file using the following code: 我可以使用以下代码保存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 

But I am not able to save the CSV file using the Save As wizard. 但是我无法使用“ 另存为”向导保存CSV文件。

The code and explanation is incomplete, but from what i understand, you need a "Save As" dialog. 代码和解释不完整,但是据我了解,您需要一个“另存为”对话框。 tkFileDialog in Tkinter should do the trick. Tkinter中的 tkFileDialog应该可以解决问题。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM