Attribute Error: 'list' object has no attribute 'split'

前端 未结 3 559
感动是毒
感动是毒 2020-11-29 01:25

I am trying read a file and split a cell in each line by a comma and then display only the first and the second cells which contain information regarding the latitude and th

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-29 01:57

    what i did was a quick fix by converting readlines to string but i do not recommencement it but it works and i dont know if there are limitations or not

    `def getQuakeData():
        filename = input("Please enter the quake file: ")
        readfile = open(filename, "r")
        readlines = str(readfile.readlines())
    
        Type = readlines.split(",")
        x = Type[1]
        y = Type[2]
        for points in Type:
            print(x,y)
    getQuakeData()`
    

提交回复
热议问题