fork download
  1. import sys
  2.  
  3. parts = 3
  4. filename = "file.txt"
  5. name, ext = filename.split('.')
  6.  
  7. data = [line for line in open(filename, "rb").read().split("\n")]
  8.  
  9. for n, part in enumerate(zip(*[iter(data)] * parts)):
  10. f = open('%s_part_%s.%s' % (name, n, ext), 'w')
  11. f.write("\n".join(part));
  12. f.close()
Runtime error #stdin #stdout #stderr 0.01s 7732KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 7, in <module>
IOError: [Errno 2] No such file or directory: 'file.txt'