Creating Sublists from a “List”

前端 未结 5 2050
余生分开走
余生分开走 2021-01-24 08:21

I have a list in a file, looks like this

c4a24534,2434b375,e750c718, .... 

I have split at \",\" and brought the below list.

x         


        
5条回答
  •  面向向阳花
    2021-01-24 09:06

    #!/usr/bin/python
    import ast
    file = open("file.txt","r")
    
    i = list()
    q = list()
    
    for line in file:
        testarray = ast.literal_eval(line)
        q.append(testarray.pop())
        i.append(testarray.pop())
    
    print(i)
    print(q)
    

    something like that ?

提交回复
热议问题