Readin a .txt file and put the elements in a list (Python)

前端 未结 3 976
南旧
南旧 2021-01-25 05:52

Im new in Python and i need some help. i got a .txt file in this form:

Time[tab]Signal

0[tab]1.05

0.5[tab]1.06

1[tab]1.09

1.5[tab]1.12

Now

3条回答
  •  暖寄归人
    2021-01-25 06:18

    don't use semicolons in python! As suspected, you are trying to read a RTF file.
    First reformat your file. I propose also an other way:

    import csv
    
    list1 = []
    with open("extedit.txt") as tsv:
        for line in csv.reader(tsv, dialect="excel-tab"):
            list1.append(line[0])
    
    del list1[0]
    print(list1)
    

提交回复
热议问题