zoukankan      html  css  js  c++  java
  • 笨办法学python(不同版本的python代码差别)

    最近在学习笨办法学python,由于安装的是python3,而教程使用的是python2,所以在代码部分有些会有差别导致编译出现问题,以此记录。

    #python3
    print
    (" Hello world!") print (3 + 2 + 1 - 5 + 4 % 2 - 1 /4 + 6) print ("what is 3 + 2?",3 + 2)
    python2
    print
    "Hello world!" print 3 + 2 + 1 - 5 + 4 % 2 - 1 /4 + 6 print "what is 3 + 2?",3 + 2
    #python3
    print
    (formatter % ( "I had this thing.", "That you could type up right.", "But it didn't sing.", "So I said goodnight." ))
    #python2
    print
    formatter % ( "I had this thing.", "That you could type up right.", "But it didn't sing.", "So I said goodnight." )
    #python3
    print
    ((end1 + end2 +end3 + end4 + end5 + end6), (end7 + end8 +end9 + end10 + end11 + end12))
    #python2
    print
    end1 + end2 +end3 + end4 + end5 + end6, print end7 + end8 +end9 + end10 + end11 + end12
    #python3
    print
    ("." * 10 )# what'd that do?
    end1 = "C"
    #Python2
    print
    "." * 10 # what'd that do? end1 = "C"
    #Python2
    print
    """ There's something going on here. With the three double-quotes. We'll be able to type as much as we like. Even 4 lines if we want,or 5,or 6. """
    #Python3
    print
    (""" There's something going on here. With the three double-quotes. We'll be able to type as much as we like. Even 4 lines if we want,or 5,or 6. """)
  • 相关阅读:
    【转】你可能不知道的Shell
    【转】28个Unix/Linux的命令行神器
    ubuntu创建桌面快捷方式
    linux解压zip乱码解决方案
    全能系统监控工具dstat
    【转】linux sar命令详解
    等级保护测评策略建议整改措施
    oracle dataguard详解和环境搭建
    Oracle RMAN备份和异机恢复
    Oracle异机恢复处理
  • 原文地址:https://www.cnblogs.com/yiduoyun0826/p/12625879.html
Copyright © 2011-2022 走看看