• python lstrip,rstrip 的 用法


    #方法一:
    import json
    s = '({"freight":[{"beforeSpecifiedTime":false,"cityCode":"","cityName":"","commitDay":60,"company":"CAINIAO_STANDARD","companyDisplayName":"AliExpress Standard Shipping","coreZone":"","currency":"USD","cutTime":"17:00","deliveryDate":"2019-09-20","deliveryDateDisplay":"other","discount":93,"discountType":"about","domesticFreight":"","errorCode":1,"errorDisplayMsg":"","isCheapestFaster":false,"isDefault":true,"isPromote":false,"isTracked":true,"localCurrency":"USD","localPrice":"0.35","localPriceFormatStr":"US $0.35","localSaveMoney":"5.02","localSaveMoneyFormatStr":"US $5.02","localTotalFreight":"5.37","localTotalFreightFormatStr":"US $5.37","logisticsDeliveryTimeType":"BUYER_PAY_ORDER","notification":"","price":"0.35","priceFormatStr":"US $0.35","processingTime":5,"promoteInformation":null,"remainTime":"-9475079","saveMoney":"5.02","saveMoneyFormatStr":"US $5.02","sendGoodsCountry":"CN","sendGoodsCountryFullName":"China","status":"","templateDiscount":"","templateType":"","time":"22","totalFreight":"5.37","totalFreightFormatStr":"US $5.37"},{"beforeSpecifiedTime":false,"cityCode":"","cityName":"","commitDay":60,"company":"EMS_ZX_ZX_US","companyDisplayName":"ePacket","coreZone":"","currency":"USD","cutTime":"17:00","deliveryDate":"2019-09-19","deliveryDateDisplay":"other","discount":74,"discountType":"about","domesticFreight":"","errorCode":1,"errorDisplayMsg":"","isCheapestFaster":false,"isDefault":false,"isPromote":false,"isTracked":true,"localCurrency":"USD","localPrice":"1.04","localPriceFormatStr":"US $1.04","localSaveMoney":"2.98","localSaveMoneyFormatStr":"US $2.98","localTotalFreight":"4.02","localTotalFreightFormatStr":"US $4.02","logisticsDeliveryTimeType":"BUYER_PAY_ORDER","notification":"","price":"1.04","priceFormatStr":"US $1.04","processingTime":5,"promoteInformation":null,"remainTime":"-9475079","saveMoney":"2.98","saveMoneyFormatStr":"US $2.98","sendGoodsCountry":"CN","sendGoodsCountryFullName":"China","status":"","templateDiscount":"","templateType":"","time":"21","totalFreight":"4.02","totalFreightFormatStr":"US $4.02"}]})'
    #注意这个s是字符类型的
    s1 = s.lstrip('(') #去除左括号
    s = s1.rstrip(')') #去除右括号
    s_dic = json.loads(s) #将字符串转成字典
    print(s_dic)

     #方法二:

      使用eval()进行处理。

      

  • 相关阅读:
    js中serialize() 序列化表单时自动url编码
    Oracle账户被锁解决:ora-28000:the account is locked
    jvm(二)------各个运行时数据库常见内存溢出分析与模拟
    解决 maven构建的web项目无法在外部Tomcat中运行的问题
    java源码分析之LinkedList(转)
    ArrayList源码剖析
    详解Swing中JTree组件的功能
    java 制作QQ登录界面
    java 类与类之间的关系 及uml图
    java 限定控制台输入值的类型
  • 原文地址:https://www.cnblogs.com/fh-fendou/p/11431643.html
Copyright © 2020-2023  润新知