Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python中的制表符和行分隔_Python - Fatal编程技术网

python中的制表符和行分隔

python中的制表符和行分隔,python,Python,我有一个附件,我需要用python上传。我需要忽略顶部的NETSIM和10值,然后读取剩余值。我使用以下代码读取python中的文件: import pandas as pd x=pd.read_csv('C:/Users/oq/Desktop/FAST/Algorithms/project/benchmark/input10.txt',sep=r'\\\t',engine='python',skiprows=(0,1,2), header=None) 我在代码中使用了制表符分隔符,但输出仍然

我有一个附件,我需要用python上传。我需要忽略顶部的
NETSIM
10
值,然后读取剩余值。我使用以下代码读取python中的文件:

import pandas as pd
x=pd.read_csv('C:/Users/oq/Desktop/FAST/Algorithms/project/benchmark/input10.txt',sep=r'\\\t',engine='python',skiprows=(0,1,2), header=None)
我在代码中使用了制表符分隔符,但输出仍然为show me,如下所示:

0                               0\t0.362291\t0.441396
1                               1\t0.156279\t0.341383
2                               2\t0.699696\t0.045577
3                               3\t0.714313\t0.171668
4                               4\t0.378966\t0.495494
5                               5\t0.961942\t0.444337
6                               6\t0.726886\t0.575888
7                               7\t0.168639\t0.406223
8                               8\t0.875627\t0.061439
9                               9\t0.540054\t0.317061
10  5\t7\t155200000.000000\t54000000.000000\t37997...
11  3\t4\t155200000.000000\t40500000.000000\t24507...
12  4\t6\t155200000.000000\t33000000.000000\t18606...
13  5\t6\t155200000.000000\t72000000.000000\t39198...
14  4\t1\t155200000.000000\t40500000.000000\t24507...
15  3\t9\t155200000.000000\t39000000.000000\t22698...
有人能告诉我怎么了吗


您希望在文本制表符上拆分,而不是字符串
\\t
,因此此处不应使用原始字符串文本。将
sep
更改为仅
'\t'

x=pd.read_csv('C:/Users/oq/Desktop/FAST/Algorithms/project/benchmark/input10.txt',sep='\t',engine='python',skiprows=(0,1,2), header=None)

我还试了一个\t。当我使用Python时,它给了我以下错误:ParserError:SAW21第17行中应该有3个字段。错误可能是因为使用多字符分隔符时忽略了引号。@OmerQureshi请尝试从
sep
前面删除
r
,例如
sep='\t'