Created
September 9, 2017 06:48
-
-
Save matdombrock/90e5ec6b3899851ec9f6cbdecee72433 to your computer and use it in GitHub Desktop.
Python Change Order of Lines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
for filename in os.listdir("."): | |
if(filename != "re.py"): | |
with open(filename, "r") as infile: | |
lines = [line for line in infile] # Read all input lines into a list | |
ordering = [0,1,2,3,4,5,6,7]#change this | |
with open(filename, "w") as outfile: | |
for idx in ordering: # Write output lines in the desired order. | |
outfile.write(lines[idx]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment