例如: str='abcba' def is_pan(str): if str==str[::-1]: print('str是回文') else: print('str1不是回文') is_pan(str)