python - Strip off characters from output -


i have following structure generated bs4, python.

['y10765227', '9884877926, 9283183326', '', 'dealer', 'rgmuthu'] ['l10038779', '9551154555', ',', ','] ['r10831945', '9150000747, 9282109134, 9043728565', ',', ','] ['b10750123', '9952946340', '', 'dealer', 'bala'] ['r10763559', '9841280752, 9884797013', '', 'dealer', 'senthil'] 

i wanna rip characters off , should following

9884877926, 9283183326, dealer, rgmuthu 9551154555 9150000747, 9282109134, 9043728565 9952946340 , dealer, bala 9841280752, 9884797013, dealer, senthil 

i using print re.findall("'([a-za-z0-9,\s]*)'", eachproperty['onclick'])

so wanna remove "[]" , "''" , "," , random id in start.

update

onclick="try{appendpropertyposition(this,'y10765227','9884877926, 9283183326','','dealer','rgmuthu');jsb9onunloadtracking();jsevt.stopbubble(event);}catch(e){};" 

so scraping onclick attribute above mentioned data.

you can use combination of str.join , str.translate here:

>>> string import punctuation, whitespace >>> lis = [['y10765227', '9884877926, 9283183326', '', 'dealer', 'rgmuthu'], ['l10038779', '9551154555', ',', ','],['r10831945', '9150000747, 9282109134, 9043728565', ',', ','], ['b10750123', '9952946340', '', 'dealer', 'bala'], ['r10763559', '9841280752, 9884797013', '', 'dealer', 'senthil']] item in lis:     print ", ".join(x x in item[1:]                                   if x.translate(none, punctuation + whitespace)) ...      9884877926, 9283183326, dealer, rgmuthu 9551154555 9150000747, 9282109134, 9043728565 9952946340, dealer, bala 9841280752, 9884797013, dealer, senthil 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -