IOError 加载数据文件到绘图时


import matplotlib.pyplot as plt
import numpy as np
x,y = np.genfromtxt('D:TanjilPythondirectoryHeat Available Datas.csv',unpack=True , delimiter=',',skip_header=0)
plt.plot(x,y,'ro--'),
plt.ylabel('Power Input (kW)'),
plt.xlabel('Speed(rpm)'),
plt.show()

但是此代码显示此错误消息:

File "C:Usersbad_tanjilAnacondalibsite-packagesnumpylib_datasource.py", line 151, in open
    return ds.open(path, mode)
  File "C:Usersbad_tanjilAnacondalibsite-packagesnumpylib_datasource.py", line 501, in open
    raise IOError("%s not found." % path)
IOError: D:TanjilPythondirectoryHeat Available Datas.csv not found.

尝试用/而不是来尝试你的道路。这就是您指定路径的方式。在字符串中充当转义字符。您也可以使用\

更改

'D:TanjilPythondirectoryHeat Available Datas.csv'

'D:\Tanjil\Python\directory\Heat Available Datas.csv'

(r'D:TanjilPythondirectoryHeat Available Datas.csv') 

相关内容

  • 没有找到相关文章

最新更新