美文网首页
Python基础语法

Python基础语法

作者: 飞翔的小骑兵 | 来源:发表于2017-07-03 09:13 被阅读8次

    输入输出

    localhost:Python clear$ python3
    Python 3.6.0 (default, Mar 16 2017, 16:06:39) 
    [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> name = input()
    cc
    >>> name
    'cc'
    >>> exit()
    

    数据类型和变量

    >>> a = 100 
    >>> if a >= 0: print(a)
    ... 
    100
    >>> a = 'i\'m ok'
    >>> print(a)
    i'm ok
    >>> true
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    NameError: name 'true' is not defined
    >>> True
    True
    >>> True and True
    True
    >>> True or False
    True
    >>> None
    >>> a = 123 
    >>> print(a)
    123
    >>> a ="ss"
    >>> print(a)
    ss
    >>> 10/3
    3.3333333333333335
    >>> 9/3
    3.0
    >>> 10//3
    3
    >>> 10%3
    1
    >>> 
    

    相关文章

      网友评论

          本文标题:Python基础语法

          本文链接:https://www.haomeiwen.com/subject/pplacxtx.html