Created
August 24, 2014 13:36
-
-
Save arsane/bb12ebd29c968ad3388c to your computer and use it in GitHub Desktop.
count chinese characters.
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/python3 | |
import sys | |
def MyCount(string): | |
tmpStr = "" | |
for c in string: | |
if ord(c)>=255 and (c not in ",。!¥()《》【】『』、?~·:“”‘’;"): tmpStr += c | |
return len(tmpStr) | |
if __name__=="__main__": | |
# print(sys.argv);exit(); | |
count=0 | |
if len(sys.argv)>0: | |
for fileName in sys.argv[1:] : | |
f=open(fileName,'r') | |
count += MyCount(f.read()) | |
f.close() | |
print(count) | |
# print(len(s)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment