|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
下列字符串中取出WO23080900320
该如何写
" {\r\n "Order_WorkOrderCode": "WO23080900320",\r\n "RowNo": "10",\r\n "Basic_ProcessCode": "260",\r\n "Describe": "YJ-26/35kV-J-400||三层共挤",\r\n "Basic_MachineCode": "JL-JL01",\r\n "Basic_ItemOutCode": "8924290111",\r\n "Basic_ItemOutVersion": "100",\r\n "Coefficient": "1",\r\n "UnitInName": "km",\r\n "UnitOutName": "km",\r\n "OrgM_DeptCode": "B13",\r\n "ProcessPlanQty": "4.767",\r\n "ErpProcessRealQty": "0",\r\n "RecId": "WO23080900320_10_",\r\n "Mdfdt": "2023/8/9 21:01:20"\r\n }",
" {\r\n "Order_WorkOrderCode": "WO23080900320",\r\n "RowNo": "20",\r\n "Basic_ProcessCode": "330",\r\n "Describe": "铜带屏蔽",\r\n "Basic_MachineCode": "JL-PB01",\r\n "Basic_ItemOutCode": "",\r\n "Basic_ItemOutVersion": "100",\r\n "Coefficient": "1",\r\n "UnitInName": "km",\r\n "UnitOutName": "km",\r\n "OrgM_DeptCode": "B13",\r\n "ProcessPlanQty": "4.767",\r\n "ErpProcessRealQty": "0",\r\n "RecId": "WO23080900320_20_",\r\n "Mdfdt": "2023/8/9 21:01:20"\r\n }",
" {\r\n "Order_WorkOrderCode": "WO23080900320",\r\n "RowNo": "50",\r\n "Basic_ProcessCode": "460",\r\n "Describe": "外护套",\r\n "Basic_MachineCode": "JL-JS03",\r\n "Basic_ItemOutCode": "",\r\n "Basic_ItemOutVersion": "100",\r\n "Coefficient": "1",\r\n "UnitInName": "km",\r\n "UnitOutName": "km",\r\n "OrgM_DeptCode": "B13",\r\n "ProcessPlanQty": "4.767",\r\n "ErpProcessRealQty": "0",\r\n "RecId": "WO23080900320_50_",\r\n "Mdfdt": "2023/8/9 21:01:20"\r\n }",
" {\r\n "Order_WorkOrderCode": "WO23080900320",\r\n "RowNo": "40",\r\n "Basic_ProcessCode": "430",\r\n "Describe": "装铠",\r\n "Basic_MachineCode": "JL-PJ01",\r\n "Basic_ItemOutCode": "",\r\n "Basic_ItemOutVersion": "100",\r\n "Coefficient": "1",\r\n "UnitInName": "km",\r\n "UnitOutName": "km",\r\n "OrgM_DeptCode": "B13",\r\n "ProcessPlanQty": "4.767",\r\n "ErpProcessRealQty": "0",\r\n "RecId": "WO23080900320_40_",\r\n "Mdfdt": "2023/8/9 21:01:20"\r\n }",
" {\r\n "Order_WorkOrderCode": "WO23080900320",\r\n "RowNo": "30",\r\n "Basic_ProcessCode": "390",\r\n "Describe": "挤包隔离套",\r\n "Basic_MachineCode": "JL-JS01",\r\n "Basic_ItemOutCode": "",\r\n "Basic_ItemOutVersion": "100",\r\n "Coefficient": "1",\r\n "UnitInName": "km",\r\n "UnitOutName": "km",\r\n "OrgM_DeptCode": "B13",\r\n "ProcessPlanQty": "4.767",\r\n "ErpProcessRealQty": "0",\r\n "RecId": "WO23080900320_30_",\r\n "Mdfdt": "2023/8/9 21:01:20"\r\n }"
你可以使用正则表达式来提取字符串中的WO23080900320。下面是一个示例代码:
import re
# 要匹配的字符串
string = '''" {\r\n "Order_WorkOrderCode": "WO23080900320",\r\n "RowNo": "10",\r\n "Basic_ProcessCode": "260",\r\n "Describe": "YJ-26/35kV-J-400||三层共挤",\r\n "Basic_MachineCode": "JL-JL01",\r\n "Basic_ItemOutCode": "8924290111",\r\n "Basic_ItemOutVersion": "100",\r\n "Coefficient": "1",\r\n "UnitInName": "km",\r\n "UnitOutName": "km",\r\n "OrgM_DeptCode": "B13",\r\n "ProcessPlanQty": "4.767",\r\n "ErpProcessRealQty": "0",\r\n "RecId": "WO23080900320_10_",\r\n "Mdfdt": "2023/8/9 21:01:20"\r\n }",
" {\r\n "Order_WorkOrderCode": "WO23080900320",\r\n "RowNo": "20",\r\n "Basic_ProcessCode": "330",\r\n "Describe": "铜带屏蔽",\r\n "Basic_MachineCode": "JL-PB01",\r\n "Basic_ItemOutCode": "",\r\n "Basic_ItemOutVersion": "100",\r\n "Coefficient": "1",\r\n "UnitInName": "km",\r\n "UnitOutName": "km",\r\n "OrgM_DeptCode": "B13",\r\n "ProcessPlanQty": "4.767",\r\n "ErpProcessRealQty": "0",\r\n "RecId": "WO23080900320_20_",\r\n "Mdfdt": "2023/8/9 21:01:20"\r\n }",
" {\r\n "Order_WorkOrderCode": "WO23080900320",\r\n "RowNo": "50",\r\n "Basic_ProcessCode": "460",\r\n "Describe": "外护套",\r\n "Basic_MachineCode": "JL-JS03",\r\n "Basic_ItemOutCode": "",\r\n "Basic_ItemOutVersion": "100",\r\n "Coefficient": "1",\r\n "UnitInName": "km",\r\n "UnitOutName": "km",\r\n "OrgM_DeptCode": "B13",\r\n "ProcessPlanQty": "4.767",\r\n "ErpProcessRealQty": "0",\r\n "RecId": "WO23080900320_50_",\r\n "Mdfdt": "2023/8/9 21:01:20"\r\n }",
" {\r\n "Order_WorkOrderCode": "WO23080900320",\r\n "RowNo": "40",\r\n "Basic_ProcessCode": "430",\r\n "Describe": "装铠",\r\n "Basic_MachineCode": "JL-PJ01",\r\n "Basic_ItemOutCode": "",\r\n "Basic_ItemOutVersion": "100",\r\n "Coefficient": "1",\r\n "UnitInName": "km",\r\n "UnitOutName": "km",\r\n "OrgM_DeptCode": "B13",\r\n "ProcessPlanQty": "4.767",\r\n "ErpProcessRealQty": "0",\r\n "RecId": "WO23080900320_40_",\r\n "Mdfdt": "2023/8/9 21:01:20"\r\n }",
" {\r\n "Order_WorkOrderCode": "WO23080900320",\r\n "RowNo": "30",\r\n "Basic_ProcessCode": "390",\r\n "Describe": "挤包隔离套",\r\n "Basic_MachineCode": "JL-JS01",\r\n "Basic_ItemOutCode": "",\r\n "Basic_ItemOutVersion": "100",\r\n "Coefficient": "1",\r\n "UnitInName": "km",\r\n "UnitOutName": "km",\r\n "OrgM_DeptCode": "B13",\r\n "ProcessPlanQty": "4.767",\r\n "ErpProcessRealQty": "0",\r\n "RecId": "WO23080900320_30_",\r\n "Mdfdt": "2023/8/9 21:01:20"\r\n }"'''
# 使用正则表达式提取WO23080900320
match = re.search(r'"Order_WorkOrderCode": "(.*?)",', string)
if match:
result = match.group(1)
print(result)
运行这段代码,你将会得到输出结果为:WO23080900320。这是通过正则表达式模式 "Order_WorkOrderCode": "(.*?)", 匹配到的结果。其中, (.*?) 表示非贪婪匹配,即尽可能少地匹配字符。
|
|