Created
January 7, 2016 14:03
-
-
Save shiywang/c15ea6c4f3184dfcc80a to your computer and use it in GitHub Desktop.
This file contains 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 fileinput | |
import sys | |
file_name = "" | |
file_buf = "" | |
file_object = "" | |
def deal_line(line): | |
global file_object | |
if line[0] == 'Q': | |
file_name = line.split(":")[1].strip() | |
file_object = open(file_name+".1", 'w+') | |
elif line[0] == 'A': | |
file_object.write(line) | |
elif line[0] == ' ': | |
file_object.close() | |
print file_buf | |
file_buf = "" | |
file_name = "" | |
else: | |
pass | |
for line in fileinput.input("3000.txt"): | |
deal_line(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment