数字(Number)类型(一)

多行语句
        Python 通常是一行写完一条语句,但如果语句很长,我们可以使用反斜杠(\)来实现多行语句,例如:

            total = item_one + \
                    item_two + \
                    item_three
        在 [], {}, 或 () 中的多行语句,不需要使用反斜杠(\),例如:

            total = ['item_one', 'item_two', 'item_three',
                    'item_four', 'item_five']
数字(Number)类型
        python中数字有四种类型:整数、布尔型、浮点数和复数。
            int (整数), 如 1, 只有一种整数类型 int,表示为长整型,没有 python2 中的 Long。
            bool (布尔), 如 True。
            float (浮点数), 如 1.23、3E-2
            complex (复数), 如 1 + 2j、 1.1 + 2.2j     
Print 输出
    print 默认输出是换行的,如果要实现不换行需要在变量末尾加上 end="":
                x="a"
                y="b"
                # 换行输出
                print( x )
                print( y )
                print('---------')
                # 不换行输出
                print( x, end=" " )
                print( y, end=" " )
                print()
以上实例执行结果为:

a
b
---------
a b  
posted @ 2019-03-29 11:01  小沐CA  阅读(187)  评论(0)    收藏  举报