python 常见错误

python2的代码在python3上运行常见错误

  • 字符串AttributeError: 'str' object has no attribute 'decode' 报错
    只需删除decode代码 因为python3上的代码默认就是utf-8编码的
  • 明明文件就在那里却报错找不到
    这时可以通过打印代码的执行路径看下当前代码与文件是否在一个路径
    建议使用相对路径 并且使用python命令行执行
  • 找不到compiler
    https://blog.csdn.net/w5688414/article/details/78489277
posted @ 2019-09-05 17:00  FromZeroToOne  阅读(274)  评论(0编辑  收藏  举报