美文网首页
python三元表达式

python三元表达式

作者: 山猪打不过家猪 | 来源:发表于2020-07-16 13:03 被阅读0次
    b=[i.strip('%') if '%' in i else i for i in a]
    
    [(tuple([erpId, day] + list(j))) for i in a for j in i]
    
    a =(['2,621', '35'],['210,852'],['2,398'],['12', '43'],['1', '09'])
    
    a = [i[0].replace(',', '') if len(i)==1 else ((i[0] + '.' + i[1]).replace(',', '')) for i in a ]
    
    >>>
    ['2621.35', '210852', '2398', '12.43', '1.09']
    
    import re
    a =[ ('636710425400', 318.09, 1, 5, '2021-04-08'), ('616873233546;\n617383035002;\n585098358905', 62.54, 1, 5, '2021-04-08'), ('39856905008', 120.5, 1, 5, '2021-04-08'), ('610474183283', 84.6, 1, 5, '2021-04-08'), ('625046034602;\n625333579394', 93.01, 1, 5, '2021-04-08'), ('608727393051;\n616119541298;\n610494565658;\n633320454564', 122.55, 1, 5, '2021-04-08')]
    ccc =[(re.findall("(\d+);",str(i[0]))[0],i[1],i[2],i[3],i[4]) if ';' in str(i[0]) else i for i in a ]
    for i in ccc:
        print(i)
    
    >>>
    ('636710425400', 318.09, 1, 5, '2021-04-08')
    ('616873233546', 62.54, 1, 5, '2021-04-08')
    ('39856905008', 120.5, 1, 5, '2021-04-08')
    ('610474183283', 84.6, 1, 5, '2021-04-08')
    ('625046034602', 93.01, 1, 5, '2021-04-08')
    ('608727393051', 122.55, 1, 5, '2021-04-08')
    

    相关文章

      网友评论

          本文标题:python三元表达式

          本文链接:https://www.haomeiwen.com/subject/rqkphktx.html