Get the length of the given string, which can be ascii string or unicode or both
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#author: rex
#blog: http://iregex.org
#filename len.py
#created: 2011-04-29 15:18
import sys
def Len(s):
'''Get the length of the given string, which can be ascii string or unicode or both'''
s=s.decode('utf8')
return len(s)
def main():
'''
get input from standard input or pipe.
args can be seperated by consecutive white space, which will be trimed to single space.
if you need to count length of the space, wrap the whole string with quotation mark.
'''
if len(sys.argv) > 1:
sentence=" ".join(sys.argv[1:])
else:
sentence=raw_input()
print Len(sentence)
if __name__ == '__main__':
main()