Skip to content

Instantly share code, notes, and snippets.

@arsane
Created August 24, 2014 13:36
Show Gist options
  • Save arsane/bb12ebd29c968ad3388c to your computer and use it in GitHub Desktop.
Save arsane/bb12ebd29c968ad3388c to your computer and use it in GitHub Desktop.
count chinese 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