小编Pra*_*him的帖子

从字符串和整数的元组,得到元组内最接近给定值的数字

给定一个带有整数的元组内部的元组,我想找到哪个数字在元组内最接近我输入的数字:

Data = (('Batik Air',int(561)),('Citilink',int(620)),('Garuda Indonesia',int(1501))
Value=500
findClosest(Data,Value)
# magic
('Batik Air',561)
Run Code Online (Sandbox Code Playgroud)

有没有办法做到这一点?

python sorting integer tuples python-3.x

2
推荐指数
1
解决办法
59
查看次数

标签 统计

integer ×1

python ×1

python-3.x ×1

sorting ×1

tuples ×1