使用scipy.genfromtxt()报错
错误代码:
Traceback (most recent call last):
File "D:/Python27/1400OS_01_Codes/code/sp_genfromtxt.py", line 3, in <module>
data=sp.genfromtxt("web_traffic.tsv",delimiter="\t")
File "D:\Python27\lib\site-packages\numpy-1.9.1-py2.7-win-amd64.egg\numpy\lib\npyio.py", line 1360, in genfromtxt
fhd = iter(np.lib._datasource.open(fname, 'rbU'))
File "D:\Python27\lib\site-packages\numpy-1.9.1-py2.7-win-amd64.egg\numpy\lib\_datasource.py", line 151, in open
return ds.open(path, mode)
File "D:\Python27\lib\site-packages\numpy-1.9.1-py2.7-win-amd64.egg\numpy\lib\_datasource.py", line 501, in open
raise IOError("%s not found." % path)
IOError: web_traffic.tsv not found.
解决办法:
程序保存为py文件,需要和读取文件"web_traffic.tsv"放在同一文件夹下。
如果该文件夹路径不在sys.path中:
import sys
sys.path.append('文件夹路径')