ImportError: cannot import name 'izip & TypeError: 'float' object cannot be interpreted as an integer


  • ImportError: cannot import name 'izip'

參考:https://codereview.stackexchange.com/questions/26271/import-izip-for-different-versions-of-python

A common idiom that I use for Python2-Python3 compatibility is:

gedit mtcnn_detector.py

try:
    from itertools import izip
except ImportError:  #python3.x
    izip = zip

However, a comment on one of my Stack Overflow answers implies that there may be a better way. Is there a more clean way to accomplish this?

  • TypeError: 'float' object cannot be interpreted as an integer

將報錯的部分全部用int()包起來,強制進行類型轉化


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM