Skip to content

Instantly share code, notes, and snippets.

@gujiaxi
Last active December 16, 2015 17:49
Show Gist options
  • Save gujiaxi/5473072 to your computer and use it in GitHub Desktop.
Save gujiaxi/5473072 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
bookList = {}
bookName = ''
clippings = open('1524.txt', 'r')
line = clippings.readline()
bookTitle = line[:-1]
bookList[bookTitle] = line
while 1:
line = clippings.readline()
bookList[bookTitle] = bookList.get(bookTitle) + line
if (line == '='*10+'\n'):
line = clippings.readline()
if not line:
break
bookTitle = line[:-1]
if not bookList.has_key(bookTitle):
bookList[bookTitle] = ''
bookList[bookTitle] = bookList.get(bookTitle) + line
clippings.close()
for title in bookList.keys():
book = open(title+'.txt', 'w')
book.write(bookList[title])
book.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment