Python 3.x 如何添加到元组值
这是代码的一个示例Python 3.x 如何添加到元组值,python-3.x,Python 3.x,这是代码的一个示例 elif longitude > longitudel and latitude < latitudel: thor = 1,-1 + thor elif经度>经度和纬度
elif longitude > longitudel and latitude < latitudel:
thor = 1,-1 + thor
elif经度>经度和纬度
我希望它改变,如果说thor=1,1,我希望它变成2,0,我已经和它混在一起有一段时间了,但我似乎找不到一种方法来让它工作,并保持它作为一个元组。有没有办法将其保持为元组,或者我必须设置单独的整数才能使其工作?您可以这样做:
thor = tuple(sum(x) for x in zip(thor, (1,-1)))
较短的方法是:
thor = tuple(map(sum, zip(thor, (1,-1))))
摘自。您能否正确设置代码格式并提供易于理解的清晰示例谢谢您的回答。