作者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/m.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