简体   繁体   中英

string split with delimiter \t

This is my code:

while 1:
    line = file.readline()
    if not line: break
    linenum += 1
    line = line.splitlines()[0]
    token = line.split('\t')

and this is a screenshot showing the local variables displayed in the debugger window:

调试器变量的屏幕截图

As you can see in debugger's image, line isn't split. Why this is happening? I tried a regular expression but split still doesn't work.

Problem is not in your code, but in your input file, It contains '\\\\t' (that is, backslash and t letter) instead of '\\t' .

Weird "capital W with strikethrough" is actually a backslash displayed in a wrong way .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM