Skip to content

Instantly share code, notes, and snippets.

@shiywang
Created January 7, 2016 14:03
Show Gist options
  • Save shiywang/c15ea6c4f3184dfcc80a to your computer and use it in GitHub Desktop.
Save shiywang/c15ea6c4f3184dfcc80a to your computer and use it in GitHub Desktop.
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