Python return list from function

后端 未结 8 960
面向向阳花
面向向阳花 2020-12-13 08:27

I have a function that parses a file into a list. I\'m trying to return that list so I can use it in other functions.

def splitNet():
    network = []
    f         


        
8条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 09:07

    L=[1, 2, 3]
    
    def rl(l): 
        return l
    
    [*ll] = rl(L) # ll is in a list
    
    ll
    # >>> [1, 2, 3]
    
    *t, = rl(L)   # ll is in a tuple
    
    t
    # >>> [1, 2, 3]
    

提交回复
热议问题