python2与python3两版本的区别是众所周知的,今天主要记录python下版本2 与版本3的区别

  • python2
In [7]: logfile  = open('/tmp/mylog.log', 'a')

In [8]: print >> logfile, 'writeen by python version 2'

In [9]: logfile.close()

In [10]: cat /tmp/mylog.log
writeen by python version 2
  • python3
In [1]: help(print)
Help on built-in function print in module builtins: print(...)
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False) Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
⇒  ipython
Python 3.5.1 (default, Jan 23 2017, 08:19:40)
Type "copyright", "credits" or "license" for more information. IPython 5.2.2 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details. In [1]: import sys In [2]: f = open('/tmp/mylog.log', 'w') In [3]: print('writeen by python version 2', file=f) In [4]: f.close() In [5]: cat /tmp/mylog.log
writeen by python version 2
writeen by python version 3

python2与python3语法区别之_重定向的更多相关文章

  1. python2 与 python3 语法区别

    python2 与 python3 语法区别 概述# 原稿地址:使用 2to3 将代码移植到 Python 3 几乎所有的Python 2程序都需要一些修改才能正常地运行在Python 3的环境下.为 ...

  2. python2 与 python3 语法区别--转

    原文地址:http://old.sebug.net/paper/books/dive-into-python3/porting-code-to-python-3-with-2to3.html 使用2t ...

  3. Python2和Python3语法区别

    1.使用for循环进行换行 python 2.x, print 不换行>>> print x, python 3.x print 不换行>>> print(x, e ...

  4. python2 与 python3的区别

    python2 与 python3的区别 几乎所有的python2程序都需要一些修改才能正常的运行在python3的环境下.为了简化这个转换过程,Python3自带了一个2to3的实用脚本.这个脚本会 ...

  5. python2 与 python3的区别总结

    python2 与 python3的区别总结    几乎所有的Python 2程序都需要一些修改才能正常地运行在Python 3的环境下.为了简化这个转换过程,Python 3自带了一个叫做2to3的 ...

  6. 详解python2 和 python3的区别

    看到这个题目大家可能猜到了我接下来要讲些什么,呵呵,对了,那就是列出这两个不同版本间的却别!搜索一下大家就会知道,python有两个主要的版本,python2 和 python3 ,但是python又 ...

  7. 详解python2 和 python3的区别-乾颐堂

    看到这个题目大家可能猜到了我接下来要讲些什么,呵呵,对了,那就是列出这两个不同版本间的却别!搜索一下大家就会知道,python有两个主要的版本,python2 和 python3 ,但是python又 ...

  8. python2和python3的区别

    python2和python3的区别 参考链接:http://www.runoob.com/python/python-2x-3x.html 1.源码上的区别 python2 python3 源码不规 ...

  9. while 运算符 初始编码 python2和python3的区别

    1.while 循环 2.运算符 3.初始编码 4.python2 和python3的区别 1.while循环: 关键词:while[循环]         break[跳出循环]         c ...

随机推荐

  1. base64图片解析

    大家可能注意到了,网页上有些图片的src或css背景图片的url后面跟了一大串字符,比如:data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAEAAAAk ...

  2. Golang学习-第一篇 Golang的简单介绍及Windows环境下安装、部署

    序言 这是本人博客园第一篇文章,写的不到位之处,希望各位看客们谅解. 本人一直从事.NET的开发工作,最近在学习Golang,所以想着之前学习的过程中都没怎么好好的将学习过程记录下来.深感惋惜! 现在 ...

  3. FW:主流RPC框架

    主流RPC框架  2015年10月27日  zman  RPC 介绍目前在互联网公司比较流行的开源的RPC框架. RPC框架比较   语言 协议 ​服务治理 ​社区 机构 Hessian 多语言 he ...

  4. Cyclic Nacklace ---hdu3746(循环节,kmp)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3746 给你一个字符串,让你在后面加尽量少的字符,使得这个字符串成为一个重复串. abca---添加bc ...

  5. Sping+ActiveMQ整合

    通过前一篇<ActiveMQ简述>大概对ActiveMQ有了一个大概的认识.本篇所阐述的是怎样通过Spring继承ActiveMQ进而更有效.更灵活的运用ActiveMQ. Spring和 ...

  6. HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM'。

    情况:WCF服务在浏览器中可以正常浏览,但是通过程序调用提示: HTTP request is unauthorized with client authentication scheme 'Anon ...

  7. 007-Shell test 命令,[],[[]]

    一.概述 test 命令用于检查某个条件是否成立,它可以进行数值.字符和文件三个方面的测试. 其中[]完全等价于test,只是写法不同.双中括号[[]]基本等价于[],它支持更多的条件表达式,还允许在 ...

  8. sails route(1) -用户定义路由

    sails支持两种类型的路由: custom(or "explicit") andautomatic(or "implicit"). 先来看一下custom 即 ...

  9. ui-select : There is no "X"(delete button) with selectize theme, when allow-clear="true"

    but add allow-clear="true"For Bootstrap and Select2 themes, it's working perfectly. reason ...

  10. 更改vim高亮括号匹配颜色

    vim括号匹配高亮显示在vim7.4版本, 默认就是开启的. 但是默认的括号匹配 高亮的颜色是浅蓝色, 在亮瞎眼的同时, 严重影响我们写代码, 最明显的感受 就是, 连续打出一对括号, 接下来不仔细看 ...