標籤:NPU 代碼 inter proc href .net bsp targe python3
通過代碼移植的報錯進行梳理!
1. print 函數的區別
Python 2.x 中可以加空格或者括弧,但是 Python 3.x 只能是括弧的
# Python 2.x>>> print "processing..."processing...>>> print("processing...")processing...# Python 3.x>>> print("processing...")processing...
2. raw_input 與 input 函數
Python 2.x 中 raw_input 與 Python 3.x 中 input 函數類似,而 Python 2.x 中的 input 函數接收數字或者帶引號字串
# Python 2.x>>> a = raw_input("Value: ")Value: Alex>>> a‘Alex‘>>> b = input("Value: ")Value: "Alex">>> b‘Alex‘# Python 3.x>>> a = input("Value: ")Value: Alex>>> a‘Alex‘
參考:python2.x和python3.x中raw_input( )和input( )區別
3. Tkinter 模組
Python 2.x 為 Tkinter,但是 Python 3.x 為 tkinter(小寫)
# Python 2.x>>> import Tkinter# Python 3.x>>> import tkinter
參考:Python GUI編程(Tkinter)
4. 除法運算子
Python 2.x 中 /、// 均為整除,但是 Python 3.x 中 / 表示除以,// 表示整除
# Python 2.x>>> 77/601>>> 77//601# Python 3.x>>> 77/601.2833333333333334>>> int(77/60)1>>> 77//601
【320】Python 2.x 與 3.x 的區別