Beispiel #1
0
def mul_test():
    s = Strings('abc')
    b = s * (1, 2, 4)
    print(b, type(b))

    print('-----------------')
    s = Strings('张三爱李四,王老五爱张三')
    c = s * {'张三': 3, '李四': 2, '讨厌': 2}
    print(c, type(c))
Beispiel #2
0
def add_test():
    """测试字符串增加int类型"""
    s = Strings('b')
    s += 1 + 1j
    s += 1
    s += 'a'
    s = s + 9.9
    print(s, type(s))

    print('---------------------')
    s = Strings('b')
    b = s + [1, 2, 3]
    print(b, type(b), s)

    print('---------------------')
    s = Strings('b')
    s += [1, 2, 3, 4]
    print(s, type(s))
Beispiel #3
0
def json_load_test():
    ds = '["伟"]'
    s = Strings(json_=ds)
    b = s.json_load(encoding='utf-8')
    print(b, type(b))

    print('---------------------------------')

    s = Strings()
    c = s.json_load(file='./json.json')
    print(c, type(c))
    os.remove('./json.json')
Beispiel #4
0
def string_in_list_subset():
    s = Strings('bc')
    print(s.string_in_list_subset(['abc', 'b', 'e'], force=False))  # 满足一个
    print(s.string_in_list_subset(['abc', 'b', 'e'], force=True))  # 满足所有
Beispiel #5
0
def subset_in_string():
    s = Strings('abc')
    print(s.list_subset_in_string(['a', 'b', 'e'], force=False))  # 满足一个
    print(s.list_subset_in_string(['a', 'b', 'e'], force=True))  # 满足所有
Beispiel #6
0
def distance_test():
    s = Strings('abcdefac')
    ls = s.distance('a', 'c')
    print(ls)
Beispiel #7
0
def find_test():
    s = Strings('aaa')
    ls = s.find('a')
    print(ls)
Beispiel #8
0
def length_test():
    s = Strings('acb')
    print(s.length())
Beispiel #9
0
def replace_test():
    import re
    s = Strings('#$ba$#')
    b = s.replace('[#$A]', '', flags=re.I)
    print(b, type(b))
Beispiel #10
0
def json_dump_test():
    ds = ['伟']
    s = Strings(json_=ds)
    b = s.json_dump(file='./json.json', ensure_ascii=False)
    print(b)
Beispiel #11
0
def join_test():
    s = Strings('#')
    b = s.join([1, 2, 3, 4j, 3.2])
    print(b, type(b))