Re: [问题] 关于判断式的问题...

楼主: apua (Apua)   2015-03-05 11:59:42
→ tiefblau: raw_input吃进来是string 03/01 23:36
推 tiefblau: 转型:加个b = int(b) 或是 用input()吃进来 推荐第一个 03/01 23:42
→ 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 不直觉的就跑过去了
作者: tiefblau (tiefblau)   2014-03-01 23:36:00
raw_input吃进来是string转型:加个b = int(b) 或是 用input()吃进来 推荐第一个因为python3就没raw_input了 还可避免人家输入奇怪东西
作者: Dong0129 (阿东跟上面讲的情况一样b)   2015-03-05 15:47:00
谢谢你,目前还正在摸索、研究,版友帮助我很多,感激不尽
作者: tiefblau (tiefblau)   2015-03-05 21:24:00
推推... 虽然我都在用py2 XDD
作者: RishYang (Rish)   2015-03-20 06:40:00
Python 2.7再战十年

Links booklink

Contact Us: admin [ a t ] ucptt.com