Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with open('temp.txt', 'r') as inpf2:
- while True:
- c = [inpf2.read(1)]
- if not c:
- break
- k = c.peek(2)
- for d in k:
- if(d == ""):
- break
- else:
- c = c.append(d)
- print c
- k = c.peek(2)
- AttributeError: 'list' object has no attribute 'peek'.
- k = inpf2.peek(2)
- from collections import deque
- with open('temp.txt') as infile:
- window = deque(infile.read(2), maxlen=3)
- nextchar = infile.read(1)
- while nextchar:
- window.append(nextchar)
- print "".join(window)
- nextchar = infile.read(1)
Add Comment
Please, Sign In to add comment