我想解析这个文件。这是一个示例片段。
'13138' => { 'REFERENCE' => '13138', 'NAME' => 'DRAPER Five 125mm Medium Grade Aluminium Oxide Sanding Discs', 'PRICE' => 108, 'MIN_QUANTITY_ORDERABLE' => 1, 'MAX_QUANTITY_ORDERABLE' => 0, 'OUT_OF_STOCK' => 0, 'DATE_PROMPT' => '', 'OTHER_INFO_PROMPT' => '', 'PRICING_MODEL' => 0, 'TAX_1' => '101=2000.00=0=', 'OPAQUE_SHIPPING_DATA' => '0.054', 'ALT_WEIGHT' => '', 'SHIP_SEPARATELY' => 0, 'SHIP_CATEGORY' => '', 'SHIP_SUPPLEMENT' => 0, 'SHIP_SUPPLEMENT_ONCE' => 0, 'HAND_SUPPLEMENT' => 0, 'HAND_SUPPLEMENT_ONCE' => 0, 'SHIP_QUANTITY' => 1, 'COST_PRICE' => 0, 'EXCLUDE_FROM_SHIP' => 0, 'ASSEMBLY_PRODUCT' => 0, 'STOCK_AISLE' => '', 'STOCK_RACK' => '', 'STOCK_SUB_RACK' => '', 'STOCK_BIN' => '', 'BARCODE' => '', 'REPORT_DESC' => '', 'PRICES' => {
1 => [
[0,108],
],
},
'CUSTOMVARS' =>
{
},
'NO_ORDERLINE' => 0, 'AUTOSHIP' => 0, 'PRODUCT_GROUP' => -1, 'THUMBNAIL' => '', 'IMAGE' => '13138_694.jpg', 'ALSOBOUGHT' => [], 'RELATED' => [], },
'13139' => { 'REFERENCE' => '13139', 'NAME' => 'DRAPER Five 125mm Coarse Grade Aluminium Oxide Sanding Discs', 'PRICE' => 96, 'MIN_QUANTITY_ORDERABLE' => 1, 'MAX_QUANTITY_ORDERABLE' => 0, 'OUT_OF_STOCK' => 0, 'DATE_PROMPT' => '', 'OTHER_INFO_PROMPT' => '', 'PRICING_MODEL' => 0, 'TAX_1' => '101=2000.00=0=', 'OPAQUE_SHIPPING_DATA' => '0.066', 'ALT_WEIGHT' => '', 'SHIP_SEPARATELY' => 0, 'SHIP_CATEGORY' => '', 'SHIP_SUPPLEMENT' => 0, 'SHIP_SUPPLEMENT_ONCE' => 0, 'HAND_SUPPLEMENT' => 0, 'HAND_SUPPLEMENT_ONCE' => 0, 'SHIP_QUANTITY' => 1, 'COST_PRICE' => 0, 'EXCLUDE_FROM_SHIP' => 0, 'ASSEMBLY_PRODUCT' => 0, 'STOCK_AISLE' => '', 'STOCK_RACK' => '', 'STOCK_SUB_RACK' => '', 'STOCK_BIN' => '', 'BARCODE' => '', 'REPORT_DESC' => '', 'PRICES' => {
1 => [
[0,96],
],
},
'CUSTOMVARS' =>
{
},
'NO_ORDERLINE' => 0, 'AUTOSHIP' => 0, 'PRODUCT_GROUP' => -1, 'THUMBNAIL' => '', 'IMAGE' => '13139_694.jpg', 'ALSOBOUGHT' => [], 'RELATED' => [], },
'13140' => { 'REFERENCE' => '13140', 'NAME' => 'DRAPER Five Extra Coarse Grade Aluminium Oxide Sanding Discs', 'PRICE' => 96, 'MIN_QUANTITY_ORDERABLE' => 1, 'MAX_QUANTITY_ORDERABLE' => 0, 'OUT_OF_STOCK' => 0, 'DATE_PROMPT' => '', 'OTHER_INFO_PROMPT' => '', 'PRICING_MODEL' => 0, 'TAX_1' => '101=2000.00=0=', 'OPAQUE_SHIPPING_DATA' => '0.055', 'ALT_WEIGHT' => '', 'SHIP_SEPARATELY' => 0, 'SHIP_CATEGORY' => '', 'SHIP_SUPPLEMENT' => 0, 'SHIP_SUPPLEMENT_ONCE' => 0, 'HAND_SUPPLEMENT' => 0, 'HAND_SUPPLEMENT_ONCE' => 0, 'SHIP_QUANTITY' => 1, 'COST_PRICE' => 0, 'EXCLUDE_FROM_SHIP' => 0, 'ASSEMBLY_PRODUCT' => 0, 'STOCK_AISLE' => '', 'STOCK_RACK' => '', 'STOCK_SUB_RACK' => '', 'STOCK_BIN' => '', 'BARCODE' => '', 'REPORT_DESC' => '', 'PRICES' => {
1 => [
[0,96],
],
},
'CUSTOMVARS' =>
{
},
'NO_ORDERLINE' => 0, 'AUTOSHIP' => 0, 'PRODUCT_GROUP' => -1, 'THUMBNAIL' => '', 'IMAGE' => '13140_694ii.jpg', 'ALSOBOUGHT' => [], 'RELATED' => [], },
这里它包含 3 个项目。它们以类似的字符串开头'13138' => { 'REFERENCE'
。并在相同类型的字符串之前结束。我怎样才能拆分这些部分?
我试过了re.search(r"{ 'REFERENCE'.*?(?={ 'REFERENCE')", catstr)
。但它不匹配。