splitting a string based on tab in the file

后端 未结 5 1392
迷失自我
迷失自我 2020-12-08 04:24

I have file that contains values separated by tab (\"\\t\"). I am trying to create a list and store all values of file in the list. But I get some problem. Here is my code.<

5条回答
  •  再見小時候
    2020-12-08 05:01

    An other regex-based solution:

    >>> strs = "foo\tbar\t\tspam"
    
    >>> r = re.compile(r'([^\t]*)\t*')
    >>> r.findall(strs)[:-1]
    ['foo', 'bar', 'spam']
    

提交回复
热议问题