delimiting carat A in python

后端 未结 1 442
醉梦人生
醉梦人生 2021-01-21 16:06

I have data in form:

37101000ssd48800^A1420asd938987^A2011-09-10^A18:47:50.000^A99.00^A1^A0^A
37101000sd48801^A44557asd03082^A2011-09-06^A13:24:58.000^A42.01^A         


        
相关标签:
1条回答
  • 2021-01-21 16:43

    If the original data uses a control-A as a delimiter, and it's just being printed as ^A in whatever you're using to list the data, you have two choices:

    1. Pipe whatever you use the list the data into a Python script that uses split('^A').

    2. Just use split('\u001') to split on actual control-A values.

    The latter is almost always going to be what you really want. The reason this didn't work from you is that you wrote split('\\u001'), escaping the backslash, so you're splitting on the literal string \u001 rather than on control-A.

    If the original data actually has ^A (a caret followed by an A) as the delimiter, just use split('^A').

    0 讨论(0)
提交回复
热议问题