Python 字符串反转函数:reverseString
以下是使用 Python 编写的函数 reverseString,它接受一个字符串参数 str,将其逆序排列,并返回结果字符串:
def reverseString(str):
return str[::-1]
使用示例:
print(reverseString('Hello World')) # 输出:dlroW olleH
print(reverseString('Python')) # 输出:nohtyP
原文地址: https://www.cveoy.top/t/topic/p29W 著作权归作者所有。请勿转载和采集!