解码和编码:
a='北京'.encode()
print(a)
b='北京'.decode()
print(b)
c='北京'.encode().decode()
print(c)
# encode 是字节 decode 是字符
计算字符串中有多少空格,多少大写字母,小写字母,多少其他字符:
def main():
s=input("input a sting:")
letter=0
space=0
digit=0
other=0
for c in s:
if c.isalpha():
letter+=1
elif c.isspace():
space+=1
elif c.isdigit():
digit+=1
else:
other+=1
print(letter,space,digit,other)
main()