output_filename = r"C:\Users\guage\Output.txt"
RRA:
GREQ-299684_6j
GREQ-299684_6k
CZM:
V-GREQ-299684_6k
V-GREQ-299524_9
F_65624_1
R-GREQ-299680_5
DUN:
FB_71125_1
FR:
VQ-299659_18
VR-GREQ-299659_19
VEQ-299659_28
VR-GREQ-299659_31
VR-GREQ-299659_32
VEQ-299576_1
GED:
VEQ-299622_2
VR-GREQ-299618_13
VR-GREQ-299559_1
VR-GREQ-299524_14
FB_65624_1
VR-GREQ-299645_1
MNT:
FB_71125_1
FB_71125_2
VR-534_4
以上是.txt文件的内容。我怎样才能单独阅读它的内容呢。例如-
RRA:VR-GREQ-299684_6j VR-GREQ-299684_6k VR-GREQ-299606_3 VR-GREQ-299606_4 VR-GREQ-299606_5 VR-GREQ-299606_7
把它保存在一个变量或类似的东西里。稍后我想单独阅读CZM等等。我做了如下。你知道吗
with open(output_filename, 'r') as f:
excel = f.read()
但是如何分开阅读呢?有人能告诉我怎么做吗?你知道吗
像这样:
然后:
您可以对文件进行迭代,并将行和索引用于您的优势;如下所示:
您可以使用文件文本
:
作为指示符来创建如下新文件:然后您应该获得文件集合:
包含所有适当的数据:
您可以替换
sf = open
和sf.write
,这是您认为最好的分离数据的方法。在这里,我使用文件。。。你知道吗相关问题 更多 >
编程相关推荐