注意:回文数为整数,小数没有回文数(我这里只做数值校验,你们也可扩展,字符串判断)
'''
@IDE :PyCharm
@Author :WangZheng
@Date :2021/11/11 21:08
@pagePath:
'''
def test(params):
# 判断接收参数是否是整数类型
if not isinstance(params, int):
print("输入整数 校验 回文数")
else:
# 转成字符串,使用字符串切片反转特性,然后 将两个数值进行比较
params = str(params)
value = params[::-1]
if value == params:
print("该数值:{} 是回文数".format(params))
else:
print("该数值:{} 是回文数".format(params))
#测试数据:例如
# 小数
# test(123.321)
# test(123.111)
# 整数
# test(121)
# test(-121)
# test(123)
# 字符串
# test("123")
# test("121")
# test("%$#@")
"""
单元测试:
1等价类:
有效:整数
无效:小数,字符串,列表,字典,对象,集合, 元祖,,,,
2 每一个分支保证都能走到
"""