search

Home  >  Q&A  >  body text

Python gets part of the data from the text?


I want to remove the key:value before the first decimal in each line, and remove the key and colon of the first key-value pair. The processing result is for example the first line. Should be
8 Timbuktu 0.022202129797066508 0.024390243902439025

滿天的星座滿天的星座2729 days ago928

reply all(2)I'll reply

  • typecho

    typecho2017-07-05 10:37:28

    a=First row of data
    b=a.split(' ')
    res=b[0]+b[1].split(':')[1]+b[3]+b[4]
    Like it and accept it

    reply
    0
  • 为情所困

    为情所困2017-07-05 10:37:28

    line.replace(/(?<=^\d )\d+:([^ ]+) [^ ]+/, '');

    Python is not installed. This is how it is represented by js (js does not support reverse order)

    reply
    0
  • Cancelreply