百万年薪python之路 -- python2和python3的区别
2024-09-01 17:04:17
python2和python3的区别:
- python2获取的是整数 python3获取的是浮点数
print函数:(Python3中print为一个函数,必须用括号括起来;Python2中print为class)
python2:
print 'Python', python_version()
print 'Hello, World!'
print('Hello, World!')
print "text", ; print 'print more text on the same line'
运行结果:
Python 2.7.6
Hello, World!
Hello, World!
text print more text on the same line
- python3:
print('Python', python_version())
print('Hello, World!')
print("some text,", end="")
print(' print more text on the same line')
运行结果:
Python 3.4.1
Hello, World!
some text, print more text on the same line
- 通过
input()
解析用户的输入:- Python3中input得到的为str;
- Python2的input的到的为int型,Python2的raw_input得到的为str类型
- python除法:
- Python3中/表示真除,//表示地板除(结果取整);
- Python2中俩整数相除/表示地板除(带上小数点/表示真除),//同样表示地板除
最新文章
- Quartz实现任务调度
- BSTR 的奥秘
- AngularJS 2 VS Code Linter环境设置
- oracle的substr函数的用法
- Myeclipse的show in breadcrumb
- struts2回显指定的错误信息
- hdu 4521 小明系列问题——小明序列(线段树 or DP)
- Twenty Questions
- ES6/ES2015核心内容
- java实现文件夹(包括其中的子文件夹、子文件)的复制——递归
- 点击按钮如何改变当前窗口的url
- 002dayPython学习编码
- Problem A: 类的初体验
- OA与BPM的区别
- 【CF944G】Coins Exhibition DP+队列
- linux中用composer安装yii框架
- 使用web页面实现oracle的安装和测试
- Hibernate 注解之 @Temporal
- 解决 The word is not correctly spelled问题
- EBS通过SQL查找所有的定时请求
热门文章
- 搭建maven本地仓库,idea应用本地maven仓库
- Python基础(十四)
- RMAN备份归档日志ORA-19575
- Openshift创建Router和Registry
- Scala 学习笔记之函数(3)
- 快学Scala 第二十课 (trait的构造顺序)
- 安卓tab,viewPaper以及frament的使用
- 定期从Docker上部署的MySQL备份数据
- spring boot项目下的application.properties中的logging.level设置日志级别
- Web Storage和cookie的区别——每日一题20190629