python使用open经常报错:TypeError: an integer is required的解决方案

错误是由于从os模块引入了所有的函数导致的,os模块下有一个open函数,接受整型的文件描述符和打开模式,from os import *引入os模块的open函数,覆盖了python内建的open函数,导致错误。
删除from os import *这行,然后再根据需要,指定引入os模块下的函数

建议任何时候都不要使用from module import *方式引入模块函数。
posted @ 2016-07-17 15:12  屌丝IT男  阅读(31918)  评论(1编辑  收藏  举报