拆开Tuple

lax_coordinates = (33.9425, -118.408056)
latitude, longitude = lax_coordinates # tuple unpacking

交换位置

variable = (10,20) # a = 10, b = 20
b,a = variable
print ("a = %d, b = %d" % (a,b))

使用Tuple可以方便的交换两个数的位置,不用设临时变量。

tuple unpacking的更多相关文章

  1. Python 系列:1 - Tuples and Sequences

    5.3 Tuples and Sequences We saw that lists and strings have many common properties, e.g., indexing a ...

  2. Python in minute

    Python 性能优化相关专题:    https://www.ibm.com/developerworks/cn/linux/l-cn-python-optim/   Python wikipedi ...

  3. python3变量和数据类型

        变量和数据类型 知识点 python 关键字 变量的定义与赋值 input() 函数 字符串的格式化 实验步骤 每一种编程语言都有它们自己的语法规则,就像我们所说的外语. 1. 关键字和标识符 ...

  4. 十二. Python基础(12)--生成器

    十二. Python基础(12)--生成器 1 ● 可迭代对象(iterable) An object capable of returning its members one at a time. ...

  5. 绘图:Matplotlib

    用于绘制一些数据图,同学推荐的,挺好用.非常好的官网文档:http://matplotlib.org/contents.html 0. 安装 可以直接pip install,还有一些依赖就按照提示来吧 ...

  6. Python3 简明教程学习(上)

    一.开始 Python 之旅交互模式 1.Ctrl + D 输入一个 EOF 字符来退出解释器,也可以键入 exit() 来退出 2.#!/usr/bin/env python3 中#!称为 Sheb ...

  7. Pyplot tutorial,Pyplot官方教程自翻译

      matplotlib.pyplot is a collection of command style functions that make matplotlib work like MATLAB ...

  8. 快速入门:十分钟学会PythonTutorial - Learn Python in 10 minutes

    This tutorial is available as a short ebook. The e-book features extra content from follow-up posts ...

  9. 【Python】远离 Python 最差实践,避免挖坑

    原文链接:http://blog.guoyb.com/2016/12/03/bad-py-style/ 最近在看一些陈年老系统,其中有一些不好的代码习惯遗留下来的坑:加上最近自己也写了一段烂代码导致服 ...

随机推荐

  1. 【自动化测试】WebDriver使用

    from selenium import webdriver from selenium.webdriver.common.keys import Keys from bs4 import Beaut ...

  2. WCF身份验证之用户名密码认证

    WCF支持多种认证技术,例如Windowns认证.X509证书.Issued Tokens.用户名密码认证等,在跨Windows域分布的系统中,用户名密码认证是比较常用的,要实现用户名密码认证,就必须 ...

  3. CodeForce-1196D2-RGB Substring (hard version)

    原题链接 题目大意与上题完全一样,只是数据规模更大. 思路: 再用上题的暴力肯定TLE,所以需要优化一下搜索过程.上一题我们是外层遍历n,内层遍历3种情况.这题我们外层遍历3种情况,内层遍历数组,记录 ...

  4. Hadoop: 在Azure Cluster上使用MapReduce

    Azure对于学生账户有260刀的免费试用,火急火燎地创建Hadoop Cluster!本例子是使用Hadoop MapReduce来统计一本电子书中各个单词的出现个数. Let's get hand ...

  5. onblur和onkeyup事件

    onblur:事件会在对象失去焦点时发生 提示:onblur 相反事件为onfocus事件 . onkeyup: 事件会在键盘按键被松开时发生. 提示:与onkeyup 事件相关的事件发生次序: on ...

  6. php开发环境是什么

    软件开发环境(Software Development Environment,SDE)是指在基本硬件和数字软件的基础上,为支持系统软件和应用软件的工程化开发和维护而使用的一组软件,简称SDE.它由软 ...

  7. Requests爬取网页的编码问题

    Requests爬取网页的编码问题 import requests from requests import exceptions def getHtml(): try: r=requests.get ...

  8. JavaScript LoopQueue

    function Queue() { var items = []; this.enqueue = function(element) { items.push(element) } this.deq ...

  9. rancher部署K8S

    环境:centos7 docker 日期准确 关闭防火墙 安装docker 创建 vim /etc/docker/daemon.json {    "registry-mirrors&quo ...

  10. spring 配置属性细节

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/qilixiang012/article/details/28233811 概要(红色为上一篇所讲,蓝 ...