'''
【程序17】题目:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。
1.程序分析:利用while语句,条件为输入的字符不为'\n'.
'''
'''
2.知识点
Python 字符串类型
python内置类str可以表示字符串类型,但Python没有character字母类型,所以str的每一个元素是一个
长度为1的str类型。
string模块提供字符串类型,它是一个不可变的字符串类型。
str类可以通过str.join()将几个小字符串组合产生一个string类型。
另外io模块中,StringIO函数也有组合字符串功能。
'''
#Python3.3.5
import string
import io
s = input('input a string:\n')
letters = 0
space = 0
digit = 0
others = 0
print(type(s))
for c in s:
print(type(c))
print(c[0])
if c.isalpha():
letters += 1
elif c.isspace():
space += 1
elif c.isdigit():
digit += 1
else:
others += 1
print('char = %d,space = %d,digit = %d,others = %d' % (letters,space,digit,others))
test = s.lower()
print(type(test))
output = io.StringIO()
output.write('fjirs\n')
print('Second line.', file=output)
contents = output.getvalue()
print('con = ',contents)
print(type(contents))