Last active
August 29, 2015 14:00
-
-
Save Congee/11399059 to your computer and use it in GitHub Desktop.
convert 2 utf-8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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