1、字符串转换 TEST to test:将字符串涉及‘T’,‘E’,‘S’,‘T’的字符全部转换为小写
msg = '''
Hello It's A TEST Program
I love Testing
Hhh, this is a Test
'''
msg = msg.strip('
')
result = []
for word in msg:
deststr = re.findall('[TEST]', word)
if len(deststr) > 0:
result.append(word.lower())
else:
result.append(word)
resultmsg = ''.join(result)
print(resultmsg)
输出:
Hello It's A test Program
I love testing
Hhh, this is a test