Created
May 11, 2016 14:52
-
-
Save binderclip/0db66d3f26aaec5ecf8aa5584f221d63 to your computer and use it in GitHub Desktop.
simple python script check if file utf-8 coding
This file contains hidden or 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
import sys | |
def main(): | |
if len(sys.argv) < 2: | |
print 'please enter file path' | |
file_path = sys.argv[1] | |
with open(file_path, 'r') as f: | |
s = f.read() | |
try: | |
s.decode('utf-8') | |
except: | |
print '%s not utf-8' % sys.argv[1] | |
# print 'finish~~' | |
if __name__ == '__main__': | |
main() | |
# print sys.argv |
Author
binderclip
commented
May 11, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment