zoukankan      html  css  js  c++  java
  • python是否需要每行以分号结束

    如果熟悉其他计算机语言,可能会习惯于每行以分号结束。

    python则不用,可以在每句末尾加上分号,但不会有任何作用。当然如果同一行内有多句代码,则每句之间是需要加上分号用来分割的。

    zhangjies-MacBook-Air:~ zhangjie$python
    Python 2.7.9 (default, Jul 14 2015, 12:18:43) 
    [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.49)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> print "hello world!"
    hello world!
    >>> print "hello world!";
    hello world!
    >>> a = 1 print a
      File "<stdin>", line 1
        a = 1 print a
                  ^
    SyntaxError: invalid syntax
    >>> a = 1; print a
    1
    >>> a = 1; print a;
    1
    >>> 
  • 相关阅读:
    实习日记7.28
    实习日记7.27
    实习总结(第三周)
    实习日记7.26
    实习日记7.25
    实习总结(第二周)
    实习总结(第一周)
    实习日记7.22
    实习日记7.21
    5月4下
  • 原文地址:https://www.cnblogs.com/orange-lover/p/7352945.html
Copyright © 2011-2022 走看看