#!/usr/bin/env python # -*- encoding: utf-8 -*- """ @Version: 1.0 @Python Version:3.6.6 @Author: ludq1 @Email: ludq1@chinaunicom.cn @date: 2023/04/07 11:40:00 @Description: """ from .my_utils import MyUtils class MyStringUtils: """ 字符串处理便捷函数 """ EMPTY = MyUtils.EMPTY @classmethod def to_str(cls, a_obj, trim: bool = False) -> str: r""" 将对象转换为字符串, 当对象为None或对其调用str()函数返回为None时,返回 EMPTY Args: a_obj: trim: Returns: """ return MyUtils.to_str(a_obj, trim=trim) @classmethod def is_empty(cls, a_str: str, trim: bool = False) -> bool: r""" 检查字符串是否是空字符串, None和''都是true,其他为false Args: a_str: trim: Returns: """ return MyUtils.is_empty(a_str, trim=trim) @classmethod def equals(cls, str1: str, str2: str) -> bool: r""" 检查两个字符串是否相同, None 和 None 相同 Args: str1: str2: Returns: """ return MyUtils.equals(str1, str2)