Python 常见错误及解决办法

错误:

Traceback (most recent call last):
 File "I:/Papers/consumer/codeandpaper/RegressionandGBDTandLR
ValueError: I/O operation on closed file

将代码:

for line in f:
    print("每一行的数据是:%s" % line)
    f.close()
改为
for line in f:
    print("每一行的数据是:%s" % line)
f.close()
就可以了。

因为:
原来的时候在for循环里进行了close,所以出错

错误:

Traceback (most recent call last):
File "C:/Documents and Settings/Administrator/Desktop/zyx", line 12, in <module>

将代码:

 “No module named 'matplotlib.pyplot'; 'matplotlib' is not a package”

脚本文件名写成了“matplotlib.py',导致pycharm不能加载正确的包。。。。

 
原文地址:https://www.cnblogs.com/shenxiaolin/p/8058163.html