Python判断字符串是否为回文
s = input().strip() # 获取输入字符串并去除首尾空格
print(s) # 输出字符串
if s == s[::-1]: # 判断是否为回文字符串
print('yes')
else:
print('no')
其中,strip() 方法用于去除字符串首尾的空格,[::-1] 表示将字符串反转。
原文地址: https://www.cveoy.top/t/topic/mJZ8 著作权归作者所有。请勿转载和采集!