"""
将列表转换为字符串, 其中';'是分隔符
替换字符串的字符
删除字符串两边的空格
将字符串切割成列表
"""
name_list = ["丁一", "王二", "张三", "李四", "赵五"]
name_list_string = ';'.join(name_list)
name_list_string = name_list_string.replace(";", " ")
name_list_string = name_list_string.strip()
new_name_list = name_list_string.split(" ")
"""
将字符串按照 分隔符' ' 转成列表元素
"""
hello_python_string = "hello my python"
hello_python_list = hello_python_string.split(' ')
"""
列表转换成字典 (删除重复元素)
"""
name_list = ["丁一", "王二", "张三", "李四", "赵五", "丁一"]
name_list = set(name_list)
量化交易之python篇 - string简单操作 - 列表转字符串、字符串切割成列表
最新推荐文章于 2022-04-28 10:43:48 发布