Skip to content

Instantly share code, notes, and snippets.

@Congee
Last active August 29, 2015 14:00
Show Gist options
  • Save Congee/11399059 to your computer and use it in GitHub Desktop.
Save Congee/11399059 to your computer and use it in GitHub Desktop.
convert 2 utf-8
#!/usr/bin/env python3
# encoding: utf-8
import os
import sys
#import chardet
dir = sys.argv[1]
#def convert(source_file):
#content = open(source_file, 'r').read().encode('UTF-8')
#open(source_file, 'w', encoding = 'UTF-8').write(content)
#open(source_file, 'w', encoding = 'UTF-8')
convert = lambda source_file: open(source_file, 'w', encoding = 'UTF-8')
def traverse():
for lists in os.listdir(dir):
path = os.path.join(dir, lists)
if os.path.isdir(path):
traverse(path)
convert(path)
if __name__ == '__main__':
traverse()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment