我想从两个单独的变量中的函数返回两个值.例如:
def select_choice():
loop = 1
row = 0
while loop == 1:
print('''Choose from the following options?:
1. Row 1
2. Row 2
3. Row 3''')
row = int(input("Which row would you like to move the card from?: "))
if row == 1:
i = 2
card = list_a[-1]
elif row == 2:
i = 1
card = list_b[-1]
elif row == 3:
i = 0
card = list_c[-1]
return i
return card
Run Code Online (Sandbox Code Playgroud)
我希望能够分别使用这些值.当我尝试使用时return i, card,它返回一个tuple …
我正在尝试编写一个列表,其中包含一个文本文件中的点列表.我设法编写了一个方法来保存一个点到文本文件.但是,我在输出中得到了一些额外的字符
try {
FileOutputStream fileOut = new FileOutputStream(path);
ObjectOutputStream out = new ObjectOutputStream(fileOut);
for(int i = 0; i < pointList.size(); i++){
String s = parseString( pointList.get(i));
out.writeObject(s);
}
out.close();
fileOut.close();
} catch (IOException i) {
i.printStackTrace();
}
private static String parseString(Point P){
String point = String.valueOf(P.getX()) + "," + String.valueOf(P.getY()) ;
System.out.println("String: " +point);
return point;
}
Run Code Online (Sandbox Code Playgroud)
这是点列表
List<Point> pointList = new ArrayList();
pointList.add(new Point(100,200));
pointList.add(new Point(300,500));
pointList.add(new Point(400,200));
pointList.add(new Point(100,500));
pointList.add(new Point(400,200![enter image description here][1]));
Run Code Online (Sandbox Code Playgroud)
这是write方法的输出

我似乎不明白如何摆脱输出第一行的字符和每行的t
谢谢你的帮助
我试图从列表中删除一个项目; 但我试图删除的项目位于
索引之前index(' ').我怎么pop()能从这个列表中的项目.
list ×2
python ×2
filewriter ×1
function ×1
indexing ×1
io ×1
java ×1
return ×1
return-value ×1