我正在尋找幫助來提取一個特定字段。使用Python提取字段
這裏是例如,我不能夠分裂並根據場數切口因爲數目可以改變由於內容改變
實施例1
[["cn","Phone",1,"","LI(\"\")","0","19%","",""],["OS_DisplayName","Display Name",1,"","LI(\"\")","1,0","19%","",""],["OS_ProductPackage","Product Package",1,"","CO(\"\",\"REQ;1_BASIC!OS!TRV;2_Messaging!OS!OEM;3_Extended!OS!EAC;4_Enhanced!OS!APO;5_Analog Port!OS!CCA;6_Contact Center Agent\",\"\",\";\",\"\",\"\")","2,0","19%","",""],["sn","Last name",1,"","LI(\"\")","3,0","12%","",""],["givenName","First name",1,"","LI(\"\")","4,0","12%","",""],["OS_SiteCode","Site Code",1,"","LI(\"\")","5,0","19%","",""]],[["917845678923","Backup","OEM","917845678923","","CNdd_RD_91784567","","cn=917845678923,cn=Subscribers,cn=np_CNdd_RnD_WangJing,cn=IPC_APAC_1_01,cn=DN,cn=Resources,cn=Users,cn=OS"]],
輸出應該是
cn=917845678923,cn=Subscribers,cn=np_CNdd_RnD_WangJing,cn=IPC_APAC_1_01,cn=DN,cn=Resources,cn=Users,cn=OS
實施例2
[["cn","Phone",1,"","LI(\"\")","0","19%","",""],["OS_DisplayName","Display Name",1,"","LI(\"\")","1,0","19%","",""],["OS_ProductPackage","Product Package",1,"","CO(\"\",\"REQ;1_BASIC!OS!TRV;2_Messaging!OS!OEM;3_Extended!OS!EAC;4_Enhanced!OS!APO;5_Analog Port!OS!CCA;6_Contact Center Agent\",\"\",\";\",\"\",\"\")","2,0","19%","",""],["sn","Last name",1,"","LI(\"\")","3,0","12%","",""],["givenName","First name",1,"","LI(\"\")","4,0","12%","",""],["OS_SiteCode","Site Code",1,"","LI(\"\")","5,0","19%","",""]],[["868694755000","Yaeng Danning","EAC","Yaeng","Dainning","CNdd_DT_86869475","","cn=868694755000,cn=Subscribers,cn=np_CNdd_DN,cn=IPC_APAC_1_01,cn=DN,cn=Resources,cn=Users,cn=OS"]],
輸出應該
cn=868694755000,cn=Subscribers,cn=np_CNdd_DN,cn=IPC_APAC_1_01,cn=DN,cn=Resources,cn=Users,cn=OS
有人可以幫助我在此。
我嘗試下面的代碼,但我不能夠使用恆定的申請號(E [8]),由於現場人數變化
e = line3.split('","","')
print "e"
print e
e = e[8].replace('"]],','').replace('","','').strip()
print "e:" ,e
'E = line3.split( '」, 「」, 「 ')' '打印e' 'E = E [8] .replace('」]], ''') .replace('「,'','')。strip()' 'print」e:「,e' –
請編輯您的帖子 - 評論並非代碼的正確位置。 –
我試過了,它正在工作現在我不能使用常量字段編號,您可以看到字段編號正在改變。 –