zoukankan      html  css  js  c++  java
  • python 数据类型_整数_浮点数

    浮点数

    >>> type(1.34)
    <class 'float'>

    整形
    >>> type(10)
    <class 'int'>

    字符行转整形

    >>> type(int("123"))
    <class 'int'>

    整形转字符

    >>> type(str(1231))
    <class 'str'>

    整形转浮点

    >>> float(123)

    123.0

    浮点转整形 丢失精度

    >>> int(123.4354353)
    123

    打印

    转义字符可以转义很多字符,比如 表示换行, 表示制表符,字符本身也要转义,所以\表示的字符就是

    print("\ \ \ \ ")

    >>> print("\ \ \ \ ")

    >>>

    r 字符串默认不转义

    print(r"\ \ \ \ ")

    >>> print(r"\ \ \ \ ")
    \ \ \ \

    布尔

    True 和 False

    >>> True
    True


    >>> False
    False

    >>> True or True
    True
    >>> True or False
    True
    >>> False or False
    False
    >>> 5 > 3 or 1 > 3
    True

    not 取反 相当于!

    >>> not True
    False
    >>> not False
    True

    and 相等于 &&

    >>> True and True
    True

    >>> True and False
    False

    or 或则 ||

    >>> True or True
    True
    >>> True or False
    True

    + - * / 

    除法是//,称为地板除 整数结果

    >>> 1 + 1
    2
    >>> 2 - 1
    1
    >>> 1 * 3
    3
    >>> 4 / 2
    2.0
    >>> 4 // 2
    2

  • 相关阅读:
    2.1 maven配置多镜像地址
    6.4 SpringData JPA的使用
    4.3 thymeleaf模板引擎的使用
    java面试题整理
    eclipse配置运行时变量
    postman上传文件
    Python定义字符串、循环
    Charles抓包
    jmeter压测
    JMeter,postman
  • 原文地址:https://www.cnblogs.com/hywhyme/p/11569305.html
Copyright © 2011-2022 走看看