zoukankan      html  css  js  c++  java
  • type convert in python

    there is no type cast in python, every conversion in python will create a new object. Not like in Java and C++, the original object will still be exist in the system.

    there are some of the built in functions in python to help the conversion. Such as:

    >>> int('123')
    123
    >>> int(45.67)
    45
    >>> round(1.15, 1)
    1.2
    >>> float(10)
    10.0
    >>> divmod(15, 6)
    (2, 3)
    >>> ord('a')
    97
    >>> chr(65)
    'A'

        round(number[, ndigits]) -> number
        
        Round a number to a given precision in decimal digits (default 0 digits).
        This returns an int when called with one argument, otherwise the
        same type as the number. ndigits may be negative.


  • 相关阅读:
    网页导出PDF文件
    图片翻转导航
    瀑布流之ajax
    楼梯效果
    数码时钟
    数字字母随机验证码
    kafka shell
    zookeeper shell
    正则
    Linux(一)
  • 原文地址:https://www.cnblogs.com/henyihanwobushi/p/2662665.html
Copyright © 2011-2022 走看看