作者apua (Apua)
看板Python
标题Re: [问题] 关於判断式的问题...
时间Thu Mar 5 11:59:42 2015
1F:→ tiefblau: raw_input吃进来是string 03/01 23:36
2F:推 tiefblau: 转型:加个b = int(b) 或是 用input()吃进来 推荐第一个 03/01 23:42
3F:→ tiefblau: 因为python3就没raw_input了 还可避免人家输入奇怪东西 03/01 23:43
补充一下:
.. code:: Python
>>> '1' > 1 # in Python2.x
True
>>> '1' > 1 # in Python3.x
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unorderable types: str() > int()
用 Python3 至少你可以更快发现错误, 而不会像 Python2 不直觉的就跑过去了
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 15.211.131.254
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Python/M.1425527985.A.625.html
4F:推 Dong0129: 谢谢你,目前还正在摸索、研究,版友帮助我很多,感激 03/05 15:47
5F:→ Dong0129: 不尽 03/05 15:47
6F:推 tiefblau: 推推... 虽然我都在用py2 XDD 03/05 21:24
7F:推 RishYang: Python 2.7再战十年 03/20 06:40