-3
A
回答
0
即:
In [1]: def pants():
...: return [1, 2, 'steve']
...:
In [2]: pants()
Out[2]: [1, 2, 'steve']
2
安德魯評論,你會如果你告訴我們,你目前正在使用的代碼獲得更好的答案。另外,如果你可以說明你使用的是什麼版本的Python,那會很好。
有幾種方法可以返回列表。比如說我們有一個叫做retlist的函數。
def retlist():
return []
將返回空列表
def retlist():
a = list()
a.append(5)
return a
將返回[5]。
您還可以使用列表解析返回一個列表
def retlist():
return [x*x for x in range(10)]
有很多方法可以返回一個列表。但基本上它涉及回報。
如果您在更詳細的回覆之後,請評論您的需求。
好運
相關問題
- 1. 需要幫助散列表
- 2. Python - 需要幫助
- 3. 需要Python幫助
- 4. Python TKinter Threading幫助需要的幫助
- 5. 我需要Python中的幫助來檢查列表的邊界
- 6. 我需要python代碼分析幫助
- 7. 我需要python作業幫助
- 8. Django的python幫助需要
- 9. 需要幫助在Python 3
- 10. 需要Python/Apache幫助
- 11. 的Python:需要幫助
- 12. Python UnboundLocalError「需要幫助」
- 13. 在Python上需要幫助
- 14. 需要Python CGI/RE幫助
- 15. Python文件需要幫助
- 16. 需要幫助的在Python
- 17. 需要幫助Python函數
- 18. 需要幫助我查詢
- 19. 需要幫助編寫和使用Python
- 20. 需要SQL幫助
- 21. 我需要幫助排列撲克牌
- 22. 我需要幫助布爾陣列
- 23. SQL需要幫助
- 24. 需要幫助我做
- 25. 需要幫助,在我的要求
- 26. 需要幫助陣列場
- 27. 需要幫助陣列
- 28. 需要幫助的列表框中
- 29. 需要幫助的算法表達列
- 30. 需要幫助搜索鏈接列表
我想你會得到更好的答案,如果你包括你使用 – 2009-01-01 10:29:50
無代碼的代碼?這一定是你的問題。要返回列表,您需要實際編寫一些代碼。 – 2009-01-01 14:01:33