示例#1
0
 def testSubObj(self):
     num = 1.0
     print(type(abs))
     # 异常检查判断
     self.assertRaises(Exception, CommonUtil.subObj, num, 0, 1)
     self.assertEqual([1, 3, 5], CommonUtil.subObj([1, 2, 3, 4, 5, 6], 0, 6, 2))
     self.assertEqual((1, 3, 5), CommonUtil.subObj((1, 2, 3, 4, 5, 6), 0, 6, 2))
示例#2
0
def subList(ls: list, start: int, end: int, step: int = 1) -> list:
    """
    分割list
    :param ls: list 
    :param start: 起始数
    :param end:  结束数
    :param step: 步长
    :return: 
    """
    return CommonUtil.subObj(ls, start, end, step)
示例#3
0
def subString(string: str, start: int, end: int, step: int = 1) -> str:
    """
    字符串切分    
    :param string: 需要切分的字符串 
    :param start: 开始
    :param end: 
    :param step: 步长
    :return: 
    """
    return CommonUtil.subObj(string, start, end, step)