Python - 读记事本++ [英] Python - Read notepad++
本文介绍了Python - 读记事本++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我有一个记事本++与以下值。我使用下面的代码试图获得结果,但所有的答案,我回来了任何人都可以帮助感谢
Hi I have a notepad++ with the following value. I used the following code trying to get the result but all the answer i got back is empty " " Can anyone please help thanks
@@New Section: Section 0:
1 2 2 1 1 9 1 1 -2 2 1 -3 3 1 1 -1 8
3 2 2 1 1 9 1 1 -2 2 1 -3 3 1 1 -1 8
4 2 2 1 1 9 1 1 -1 1 1 -2 2 1 1 -1 8
我的代码:
reader = list(csv.reader(open(file_path_Inplane, 'rb')))
line = reader[3][0]
Sat = line.split(' ')
Sat = Sat[len(Sat)-1]
line = reader[1][0]
Coer = line.split(' ')
Coer = Coer[len(Coer)-1]
推荐答案
默认情况下, csv
reader对象需要逗号作为分隔符不在您的示例文件中使用。如果它实际上是标签,那么你可以使用
By default, csv
reader objects expect commas as separators, which aren't used in your example file. If it's actually tabs, then you can use
reader = list(csv.reader(open(file_path_Inplane, 'rb'), delimiter="\t"))
如果它是空格,我想你会更好
If it's spaces, I think you'd be better off with
reader = [line.split() for in in open(file_path_Inplane)]
这篇关于Python - 读记事本++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文