本港台最快开奖结果_本港台118kj开奖现场_明日大富翁开奖结果

[2019]本港台最快开奖结果是给大家带来了一个可以免费下载正版的机会,1本港台118kj开奖现场为玩家提供免费好玩的iPad游戏下载,点击明日大富翁开奖结果了解更多优惠信息,因为只有在注册之后下载下来的平台才是官方指定的。

python2纯正除法

来源:http://www.alloutofdebt.com 作者:本港台118kj开奖现场 人气:159 发布时间:2019-12-16
摘要:python2和python3除法的最大区别: python2: print 500/1000 python2结果: 取整数部分,小数并没有保留 0Process finished with exit code 0   python3: print 500/1000 python3结果: 得到真实结果,小数保留 0.5Process fin

python2和python3除法的最大区别:

python2:

print 500/1000

python2结果:取整数部分,小数并没有保留

0

Process finished with exit code 0

 

python3:

print 500/1000

python3结果:得到真实结果,小数保留

0.5

Process finished with exit code 0

 

那么,如果python2想保留小数部分,要怎么做呢?

只需要增加一个导入包.就可以了.并不需要其它操作

from __future__ import division #用于/相除的时候,保留真实结果.小数

 

增加导入包后的,python2操作:

#coding:utf-8
from __future__ import division

print 500/1000

结果:

0.5

Process finished with exit code 0

 

还有另一种方式.将除数或被除数两个其它至少一个转换成float型:

print float(500)/1000

结果:

0.5

Process finished with exit code 0

 

 

 

 

G

M

T

 

Detect language Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bengali Bosnian Bulgarian Catalan Cebuano Chichewa Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Esperanto Estonian Filipino Finnish French Galician Georgian German Greek Gujarati Haitian Creole Hausa Hebrew Hindi Hmong Hungarian Icelandic Igbo Indonesian Irish Italian Japanese Javanese Kannada Kazakh Khmer Korean Lao Latin Latvian Lithuanian Macedonian Malagasy Malay Malayalam Maltese Maori Marathi Mongolian Myanmar (Burmese) Nepali Norwegian Persian Polish Portuguese Punjabi Romanian Russian Serbian Sesotho Sinhala Slovak Slovenian Somali Spanish Sundanese Swahili Swedish Tajik Tamil Telugu Thai Turkish Ukrainian Urdu Uzbek Vietnamese Welsh Yiddish Yoruba Zulu   Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bengali Bosnian Bulgarian Catalan Cebuano Chichewa Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Esperanto Estonian Filipino Finnish French Galician Georgian German Greek Gujarati Haitian Creole Hausa Hebrew Hindi Hmong Hungarian Icelandic Igbo Indonesian Irish Italian Japanese Javanese Kannada Kazakh Khmer Korean Lao Latin Latvian Lithuanian Macedonian Malagasy Malay Malayalam Maltese Maori Marathi Mongolian Myanmar (Burmese) Nepali Norwegian Persian Polish Portuguese Punjabi Romanian Russian Serbian Sesotho Sinhala Slovak Slovenian Somali Spanish Sundanese Swahili Swedish Tajik Tamil Telugu Thai Turkish Ukrainian Urdu Uzbek Vietnamese Welsh Yiddish Yoruba Zulu          

 

 

 

Text-to-speech function is limited to 200 characters

 

  Options : History : Feedback : Donate Close

本文由本港台最快开奖结果发布于本港台118kj开奖现场,转载请注明出处:python2纯正除法

关键词:

上一篇:没有了

下一篇:揭开yield关键字的神秘面纱

频道精选

最火资讯

  • Windows程序设计
    刚开始学习Windows程序设计,磕磕碰碰,先做个小笔记缓...
  • python爬取知网
    最近在练习写爬虫的时候,正巧同学的女朋友有需求,大...
  • 常用命令
    常用命令集合 文件查找 find、locate find find:文件查找,针...
  • 十年WEB技巧升高进度
    十年WEB技术发展历程 2015/07/19 · HTML5 ·WEB 原文出处: 红...
  • 每一日一个Linux命令
    rm命令 可以删除一个目录中的一个或多个文件或目录,也...
  • PE结构分析
    在 PE文件头的 IMAGE_OPTIONAL_HEADER 结构中的 DataDirectory(数据...