
刚装的python3.2
才接触
哪个帮忙解答下疑惑
??jtshs256 写了:3?还是用2吧……
代码: 全选
[root@ThinkPad-X100e ~]# python2
Python 2.7.1 (r271:86832, Feb 21 2011, 01:28:26)
[GCC 4.5.2 20110127 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 1/2
0
>>> 1.0/2
0.5
1/2 和 1//2adagio 写了:建议看看小学数学
enzymer 写了:In Python 3 the division operator ( / ) will always perform floating point division, and you must use ( // ) to perform integer division.
refer: http://www.summet.com/dmsi/html/introPython3.html