拆开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. sql 为什么要用where 1=1?

    之前一直不太明白,sql语句里为什么要写where 1=1 提升某种执行效率? 其实,1=1 是永恒成立的,意思无条件的,也就是说在SQL语句中有没有这个1=1都可以. 这个1=1常用于应用程序根据用 ...

  2. 软件体系结构-分层、代理、MVC、管道与过滤器

    什么是软件架构? 程序或计算系统的软件体系结构是系统的一个或多个结构,包括软件元素.这些元素的外部可见属性以及它们之间的关系. ——Software Engineering Institute(SEI ...

  3. Markov Decision Process in Detail

    From the last post about MDP, we know the environment consists of 5 basic elements: S:State Space of ...

  4. mybatise根据list参数查询

    where id in<foreach item="item" index="index" collection="map.idList&quo ...

  5. Lambda -语法使用,代码简化

    使用Lambda的方式实现线程 线程中()是run方法的(),可用来接受参数,格式: new Thread(()->{ System.out.println(Thread.currentThre ...

  6. mysql时间增加一年

    update siteserver_content_57 set AddDate=DATE_ADD(AddDate,INTERVAL 2 year),LastHitsDate=DATE_ADD(Las ...

  7. 常见样式问题七、word-break、word-wrap、white-space区别

    常见样式问题七.word-break.word-wrap.white-space区别:https://blog.csdn.net/c11073138/article/details/79534394 ...

  8. BZOJ 4821 (luogu 3707)(全网最简洁的代码实现之一)

    题面 传送门 分析 计算的部分其他博客已经写的很清楚了,本博客主要提供一个简洁的实现方法 尤其是pushdown函数写得很简洁 代码 #include<iostream> #include ...

  9. UVAlive 6756 Increasing Shortest Path

    We all love short and direct problems, it is easier to write, read and understand the problem statem ...

  10. 【学习总结】gcc和gdb

    目录 <> vim.gcc.gdb: gcc: gcc和g++是c/c++的linux系统集成的编译器,源文件的后缀应为 .C/.cpp/.c++/.cc等 编译器可以将C.C++等语言源 ...