python浮点数转换整数_Python | 将输入强制转换为整数,浮点型

python浮点数转换整数

To input any value, we use input() function – which is an inbuilt function.

要输入任何值,我们使用input()函数-这是一个内置函数。

输入转换为整数 (Typecasting input to integer)

Syntax:

句法:

    int(input())

Example:

例:

# input a number
num = int(input("Input a value: "))

# printing input value 
print "num = ", num

Output

输出量

Input a value: 10
num =  10

类型转换输入浮动 (Typecasting Input to float)

Syntax:

句法:

    float(input())

Example:

例:

# input a number
num = float(input("Input a value: "))

# printing input value 
print "num = ", num

Output

输出量

Input a value: 10.23
num =  10.23



翻译自: https://www.includehelp.com/python/typecasting-input-to-integer-float.aspx

python浮点数转换整数

    原文作者:cumubi7453
    原文地址: https://blog.csdn.net/cumubi7453/article/details/107797431
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞