Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import os
- folder = "C:/pytemp/"
- try: os.mkdir(folder)
- except: pass
- filename = 'mytargetfile.txt'
- fullpath = folder + filename
- # Open the file for reading
- # Open the file for writing -- Note if to append the data... change the 'w' to 'a'
- source = open(fullpath, 'w+')
- source.write( "Python is a great language!\n\n-- End of Demo --\n");
- # Close opened file
- source.close()
- # Open the file for reading
- source = open(fullpath, 'r')
- # Read the file
- data = source.read()
- print data
- # Close the output file... as for good measure
- source.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement