Python入门之modf()方法的使用
作者:goldensun 发布时间:2023-02-27 10:11:53
标签:Python
modf()方法返回两个项的元组x的整数小数部分。这两个元组具有相同x符号。则返回一个浮点数的整数部分。
语法
以下是modf()方法的语法:
import math
math.modf( x )
注意:此函数是无法直接访问的,所以我们需要导入math模块,然后需要用math的静态对象来调用这个函数。
参数
x -- 这是一个数值表达式
返回值
这种方法在两项的元组返回x的整数小数部分。具有相同的x符号。整数部分则返回一个浮点数。
例子
下面的例子显示了modf()方法的使用。
#!/usr/bin/python
import math # This will import math module
print "math.modf(100.12) : ", math.modf(100.12)
print "math.modf(100.72) : ", math.modf(100.72)
print "math.modf(119L) : ", math.modf(119L)
print "math.modf(math.pi) : ", math.modf(math.pi)
当我们运行上面的程序,它会产生以下结果:
math.modf(100.12) : (0.12000000000000455, 100.0)
math.modf(100.72) : (0.71999999999999886, 100.0)
math.modf(119L) : (0.0, 119.0)
math.modf(math.pi) : (0.14159265358979312, 3.0)
0
投稿
猜你喜欢
- MySQL中SQL Mode的查看与设置MySQL可以运行在不同的模式下,而且可以在不同的场景下运行不同的模式,这主要取决于系统变量 sql
- 1.相关函数的讲解image_to_data()的输出结果是表格形式,输出变量的类型依旧是字符串。你会得到一个这样的列表['leve
- 实现功能excel表格中有4列数,分别为RMF计算得到的 β,γ,势能面及组态,需要挑选出相同 β 值下势能面最低时的组态。为了减小数据量,
- #!/usr/bin/env pythonimport sys,timefrom socket import socketdef read_
- 在Oracle数据库中,如何查找,定位一张表最后一次的DML操作的时间呢? 方式有三种,不过都有一些局限性,下面简单的解析、总结一下。1:使
- 本文将以实战的形式基于scipy模块使用Python实现简单滤波处理,包括内容有1.低通滤波,2.高通滤波,3.带通滤波,4.带阻滤波器。具
- 1、创建Django项目打开pycharm,新建Django项目,可以选择一个虚拟环境建完之后目录如下:2、创建应用,我这里命名为demo在
- 一、前言使用过Python的同学们一定被她的各种编码问题缠绕过,因为平常维护的新老项目跨越 2、3两个版本,编码问题有时更是让我苦不堪言,遂
- 本文实例讲述了Python lxml模块的基本使用方法。分享给大家供大家参考,具体如下:1 lxml的安装安装方式:pip install
- 前言:本博客只是因为我正在上计算机图形学这门课,为了方便复习所写,所以内容的正确性不敢保证,各位观看之前请三思(欢迎大佬提出建议)为VS20
- Beautiful Soup 库一般被称为bs4库,支持Python3,是我们写爬虫非常好的第三方库。因用起来十分的简便流畅。所以也被人叫做
- 本文将带领大家由浅入深的去窥探一下,这个装饰器到底是何方神圣,看完本篇,装饰器就再也不是难点了.一、什么是装饰器网上有人是这么评价装饰器的,
- Oracle客户端精简后的文件,可以实现数据库的通信,直接和软件打包: 第一步:拷贝文件:主要是四个目录:bin,nls,oracore,N
- EMS-员工信息管理系统MySQL学习之基础操作总结MySQL学习之基础命令实操总结创建ems库show databases;
- 整个重装步骤大致分四个步骤进行,第一步,备份原mysql中的所有数据库。第二步,完全卸载mysql第三步,下载安装新版mysql第四步,导入
- requests安装和使用下载安装:pip install requests#requests模块import requests#发送请求
- 进入智联招聘官网,在搜索界面输入‘数据分析师',界面跳转,按F12查看网页源码,点击network 选中XHR,然后刷新网
- 我就废话不多说啦,还是直接看代码吧!try: print(a)except Exception as e: prin
- 关于文件名:必须以如下方式命名,不要乱起名,也无需专门手动控制加载哪个文件.env 全局默认配置文件,不论什么环境都会加载合并.env.de
- 前言在日常工作或者学习中,操作数据库时候难免会因为“大意”而误操作,需要快速恢复的话通过备份来恢复是不太可能的,下面这篇文章主要给大家介绍关