Advertisement
alvations

readlines() bug

Dec 3rd, 2013
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. import urllib2, codecs, os
  2.  
  3. txt = urllib2.urlopen('http://www.unicode.org/udhr/d/udhr_bba.txt').read()
  4. with codecs.open('test.txt','w','utf8') as fout:
  5.   print>>fout, txt
  6.  
  7. print len(codecs.open('test.txt','r','utf8').readlines())
  8. with codecs.open('test.txt','r','utf8') as fin:
  9.   for _ in range(5): fin.readline()
  10.   print len(fin.readlines())+5
  11.  
  12. os.remove('test.txt')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement