I am not able to open an excel file to write data using following code in python 2.7.3.
What is wrong with this code?
def openfile():
import os
f=open('ab.xls', 'w')
return
import Tkinter
from Tkinter import *
root=Tk()
root.geometry('100x100+100+100')
button1=Button(root, text='Open file', command=openfile)
button1.pack()
root.mainloop()
Thanks
You seem to be confused about what open means in this context.
open()is a function that returns a file handle in Python so you can read the data into your application.If you want to open the file with the default program on your system for that filetype, look into os.startfile().