f = open('test.txt', 'w') f.write('Hello, ') f.write('World!') f.close() f = open('test.txt', 'r') print f.read(4) print f.read()