How to change the list separator in python?

后端 未结 2 2081
忘了有多久
忘了有多久 2021-01-29 15:20

I have a list

[u\'Scanned by CamS\\nINCOME TAN DEPARTMENT\\nINDER SINGH\\nAMAR JEETSINGH FIORA\\n2407/1985\\nMimi\\nAAPPF5793,\\nGOVT of INDIA\\n\']
2条回答
  •  别那么骄傲
    2021-01-29 15:27

    using split on first list item (desired string) :

    l = [u'Scanned by CamS\nINCOME TAN DEPARTMENT\nINDER SINGH\nAMAR JEETSINGH FIORA\n2407/1985\nMimi\nAAPPF5793,\nGOVT of INDIA\n']
    l =  l[0].split('\n')
    l # ['Scanned by CamS', 'INCOME TAN DEPARTMENT', 'INDER SINGH', 'AMAR JEETSINGH FIORA', '2407/1985', 'Mimi', 'AAPPF5793,', 'GOVT of INDIA', '']
    

    last element is empty because of last '\n'

提交回复
热议问题