Guest User

Untitled

a guest
Sep 25th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. # Python 2:
  2. os.walk(u'.')
  3.  
  4. # Python 3:
  5. os.walk('.')
  6.  
  7. >>> u'я'.encode('cp866')
  8. b'xef'
  9. >>> u'я'.encode('cp1251')
  10. b'xff'
  11. >>> u'я'.encode('utf-8')
  12. b'xd1x8f'
  13.  
  14. >>> b'xef'.decode('cp866')
  15. u'я'
  16. >>> b'xef'.decode('latin-1')
  17. u'ï'
  18.  
  19. #!/usr/bin/env python2
  20. import io
  21. import sys
  22.  
  23. with io.open('files_to_remove.txt', encoding='utf-8') as file:
  24. for path in file:
  25. path = path.strip()
  26. try:
  27. os.remove(path)
  28. except OSError, e:
  29. print >>sys.stderr, "warning: can't remove %r, reason: %s" % (path, e)
Add Comment
Please, Sign In to add comment