字符串反转:Python代码实现

本程序使用Python代码实现字符串反转功能,将输入的字符串倒序输出。

解题思路

直接将字符串倒序输出即可。

Python代码

string = input("请输入一个字符串:")
reversed_string = string[::-1]
print('反序后的字符串:', reversed_string)

示例

输入: 'Hello, world!'

输出: '!dlrow ,olleH'

字符串反转:Python代码实现

原文地址: https://www.cveoy.top/t/topic/nW7H 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录