def check_str(value): # 檢查你輸入的是否是字符類型 if isinstance(value, str): # 判斷字符串以什么結尾 if value.endswith('.sh'): return '%s 是以.sh結尾的字符串' % value # 判斷字符串以什么開頭 elif value.startswith('xi'): return '%s 是以xi開頭的字符串' % value else: return '%s 不滿足以上條件的字符串' % value else: return '%s is not str' % value