zoukankan      html  css  js  c++  java
  • Python 自用代码(递归清洗采标情况)

    将‘ISO 3408-1-2006,MOD  ISO 3408-2-1991,MOD  ISO 3408-3-2006,MOD’类似格式字符串存为:

    [{'code': 'ISO 3408-1-2006', 'type': 'MOD'}, {'code': 'ISO 3408-2-1991', 'type': 'MOD'}, {'code': 'ISO 3408-3-2006', 'type': 'MOD'}]格式

    #coding=utf-8
    
    s = 'ISO 3408-1-2006,MOD  ISO 3408-2-1991,MOD  ISO 3408-3-2006,MOD'
    
    def func(string, ls):
        dc = {}
        loc = string.find(',')
        if loc==-1:
            return ls
        else:
            dc["code"] = string[:loc].strip()
            dc["type"] = string[loc+1:loc+4]
            ls.append(dc)
            return func(string[loc+4:],ls)
    
    if __name__ == '__main__':
        ls = []
        z = func(s, ls)
        print z
  • 相关阅读:
    vue $emit的使用
    flask config 环境变量配置
    get请求
    下载及安装
    测试用例写作
    系统测试
    测试方法
    软件质量
    测试基础
    子网掩码
  • 原文地址:https://www.cnblogs.com/zhangtianyuan/p/7090686.html
Copyright © 2011-2022 走看看