自动设置str列表并设置列表名称

时间:2018-11-21 16:25:14

标签: python-3.x pandas list dataframe

我的程序遇到问题,我希望程序使用两列来识别txt中的字符串,然后将txt的字符串放入两列中具有行名的列表中,现在不知道如何自动创建列表,但是我仍然想制作一个程序,将他在txt中识别的所有内容都放入列表中。

link = "excelfilett.txt"
file = open(link, "r")
frames_path = []
is_count_frames_path = False
for line in file:
    if "[Routing Paths]" in line:
        is_count_frames_path = True
    if is_count_frames_path== True:
        for row in df_frame_array_load["[Name]"]:
            if row in line:
                a = line[0:4]
                a = list(a)
            if "[EthernetComNeed]" in line:
                break
        for row in df_frame_array_load["[Name2]"]:
            if row in line:
                a = line[0:4]
                a = list(a)
            if "[EthernetComNeed]" in line:
                break
    if "[EthernetComConfig]" in line:
        break
print(a)

但这只能给我这个:

  

['F','L','_','9']

当我想要类似的东西时:

  

['FL_1','FL_1','FL_2','FL_9']

关于如何执行此操作的任何想法?

0 个答案:

没有答案