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. """)
  • 相关阅读:
    再见了,正则表达式
    深入理解 Python 描述符
    并发-ScheduledThreadPoolExecutor
    ScheduledExecutorService用法
    常见限流算法总结
    常见集合类的复杂度
    并发-ConcurrentHashMap 1.7和1.8的区别
    并发-HashMap在jdk1.8也会出现死循环
    并发-Hashmap 1.7和1.8有哪些区别
    并发-HashMap与红黑树-todo
  • 原文地址:https://www.cnblogs.com/yiduoyun0826/p/12625879.html
Copyright © 2011-2022 走看看