prev | Python file operation - Writing into a file #this function will open/create a file and write into it def file_open(filename): """create a file and write into it""" print 'opening the file:',filename try: fo=open(filename,'w+'); # open the file except: print 'Error in program' else: fo.write("Linux Programmers Paradise\n"); fo.close(); #get file name from keyboard name = raw_input ('whats the file name?\n') print 'file name is : ',name,'.' #call the function file_open(name); |