【发布时间】:2014-04-10 21:59:41
【问题描述】:
我用 Python 编写了这段代码:
liste_usager = input("Veuillez entrer la liste d'entiers:")
liste = []
for n in liste_usager.split(' '):
liste.append(int(n))
print(liste)
return liste
print('liste enregistrée')
print('que voulez-vous faire?')
boucle = True
while boucle:
print('''
1-afficher la liste
2-trier la liste
3-afficher la valeur maximale
4-afficher la valeur minimale
5-afficher la somme des valeurs
6-inverser la liste
7-modifier la liste
0-retour
''')
choix= input('choissisez une commande:')
if choix =='1':
print(liste_usager)
if choix =='2':
menu_tri()
else:
boucle= False
这只是返回一个整数列表,例如[1,2,3]。我的问题是我在同一个.py 文件中有其他def 函数/模块,这些模块需要使用这个gestionliste() 模块的结果列表。例如一个模块对列表进行排序,但是如何保持列出或将其转移到其他模块/功能而不再次询问用户?谢谢!
【问题讨论】:
-
我认为你在上次编辑中杀死了一些东西。函数的
def在哪里? -
非常不清楚函数中有什么,没有什么。你能显示你的实际代码吗?最好把不需要的部分剪掉(比如打印语句)
-
您在我的问题中看到的所有代码都是我的 def() 函数中我要求列表的内容。现在我需要“保存”结果列表以在其他模块中使用它(例如你可以在我的代码中看到的 menu_tri() 但实际上是另一个必须使用列表的 def() 函数。我不知道该怎么做。谢谢
标签: python list function module