Python 字符串元音替换:将元音字母替换为下一个字母
string = input('请输入字符串:')
vowels = 'aeiouAEIOU'
new_string = ''
for char in string:
if char in vowels:
new_string += chr(ord(char) + 1)
else:
new_string += char
print('替换后的字符串为:', new_string)
示例输出:
请输入字符串:Hello World
替换后的字符串为: Hfmmp Xpsme
原文地址: https://www.cveoy.top/t/topic/j53y 著作权归作者所有。请勿转载和采集!