Fork me on GitHub

大小写转换

运行环境python3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def UCaseChar(ch):
if ord(ch) in range(97, 122):
return chr(ord(ch) - 32)
else:
return ch
def LCaseChar(ch):
if ord(ch) in range(65, 91):
return chr(ord(ch) + 32)
else:
return ch
def UCase(str):
return ''.join(map(UCaseChar, str))
def LCase(str):
return ''.join(map(LCaseChar, str))
print (LCase('ABC我abc'))
print (UCase('ABC我abc'))

Your support will encourage me to continue to create!