码迷,mamicode.com
首页 > 编程语言 > 详细

Python 2.X-关于函数返回的数值类型

时间:2016-01-31 02:36:15      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:

在使用同一个函数,相同的参数的时候,参数在传递的过程中使用了不同的形式(有无小数点)决定了该函数返回的值的类型。

# -*- coding:utf-8 -*-

def return_types(one, two):
    return (one / two)

int_type = return_types(3, 2)
print "%f" % int_type

float_type = return_types(3.0, 2.0)
print "%f" % float_type

下面为运行结果。

 1.000000
 1.500000

 

Python 2.X-关于函数返回的数值类型

标签:

原文地址:http://www.cnblogs.com/UncleXiang/p/5172265.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!