拆开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. shapefile文件数据结构

    头部 点 线 面 序号 x,y,... 线 序号 1,2 面 序号 1,2,3 拓扑检查 ... <GIS数据结构与算法>

  2. UE4开发PSVR游戏,使用RazorGPU进行调试的方法

    打开Project Launcher,如果没有需要的Devkit平台目标,就点下方的Device Manager,右键Claim 相应的目标.如果已经出现在Project Launcher中,点击上方 ...

  3. 学习笔记11 EF查询相当于sql 中的 where in

    两种写法 1. int[] Ids={1,2,3} DBContainer db=new DBContainer(); var list=db.表明.where(a=>Ids.Contains( ...

  4. CSU 1554 SG Value (multiset/priority queue 思维题)

    题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1554 Description The SG value of a set (mult ...

  5. 金山云无法ping通外网

    解决方法:在网络安全组中放行ping端口.

  6. selenuim&PhantomJS&Beautifulsoup练习经典实例

    # coding = utf-8__autor__ = 'litao' from selenium import webdriverfrom selenium.webdriver.common.by ...

  7. Flask变量规则(构建动态url)

    原文出处: http://codingdict.com/article/4867 可以通过将可变部分添加到规则参数来动态构建URL.这个变量部分被标记为 < variable-name>. ...

  8. 为什么从pycharm中打开的html文件会显示404?

    问题如图: 解决办法: 某次发现运行导入的html文件的时候,打开浏览器会报404错误:而运行自己写的html文件则正常显示:最后发现这是pycharm缓存问题,只需重启pycharm清除缓存就ok啦 ...

  9. 《图解设计模式》读书笔记4-2 STRATEGY模式

    目录 示例程序 角色 想法 Strategy模式即策略模式,在编程中,策略指的就是算法.利用此模式可以整体替换算法,即使用不同方式解决同一个问题.比如设计一个围棋程序,通过切换算法可以方便地切换AI的 ...

  10. linux RZ 命令

    root 账号登陆后,依次执行以下命令: 1 cd /tmp 2 wget http://www.ohse.de/uwe/releases/lrzsz-0.12.20.tar.gz 3 tar zxv ...