Python return list from function

后端 未结 8 937
面向向阳花
面向向阳花 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:10

    Have you actually called the function yet? This works fine (in the Python interpreter)

     >>> def f():
     ...   network = []
     ...   network.append(1)
     ...   network.append(2)
     ...   network.append(3)
     ...   return network
     ...
     >>> network = f()
     >>> print network
     [1, 2, 3]
    

提交回复
热议问题