本文介绍了如何从 Python 中的元组中获取整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含两个数字的元组,我需要获取两个数字.第一个数字是 x 坐标,而第二个数字是 y 坐标.我的伪代码是我关于如何去做的想法,但是我不太确定如何使它工作.
I have a tuple with two numbers in it, I need to get both numbers. The first number is the x-coordinate, while the second is the y-coordinate. My pseudo code is my idea about how to go about it, however I'm not quite sure how to make it work.
伪代码:
tuple = (46, 153)
string = str(tuple)
ss = string.search()
int1 = first_int(ss)
int2 = first_int(ss)
print int1
print int2
int1 将返回 46,而 int2 将返回 153.
int1 would return 46, while int2 would return 153.
推荐答案
int1, int2 = tuple
这篇关于如何从 Python 中的元组中获取整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!