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

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-06
  • 2021-10-02
  • 2022-12-23
猜你喜欢
  • 2021-11-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2021-10-21
相关资源
相似解决方案