-
-
Save gzxultra/fcf9479f4f7b0ac341a271bd25422002 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
gzxultra
commented
Jun 2, 2016
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment