我想用genformtxt()加載一個txt文件。該txt文件已經在c :.numpy.genfromtxt路徑值
stock=np.genfromtxt('c:\09012017.txt',delimiter=' ',dtype=str,skip_header=1)
C:\Anaconda3\lib\site-packages\numpy\lib\npyio.py in genfromtxt(fname, dtype, comments, delimiter, skip_header, skip_footer, converters, missing_values, filling_values, usecols, names, excludelist, deletechars, replace_space, autostrip, case_sensitive, defaultfmt, unpack, usemask, loose, invalid_raise, max_rows)
1549 fhd = iter(np.lib._datasource.open(fname, 'rbU'))
1550 else:
-> 1551 fhd = iter(np.lib._datasource.open(fname, 'rb'))
1552 own_fhd = True
1553 else:
C:\Anaconda3\lib\site-packages\numpy\lib\_datasource.py in open(path, mode, destpath)
149
150 ds = DataSource(destpath)
--> 151 return ds.open(path, mode)
152
153
C:\Anaconda3\lib\site-packages\numpy\lib\_datasource.py in open(self, path, mode)
492
493 # NOTE: _findfile will fail on a new file opened for writing.
--> 494 found = self._findfile(path)
495 if found:
496 _fname, ext = self._splitzipext(found)
C:\Anaconda3\lib\site-packages\numpy\lib\_datasource.py in _findfile(self, path)
335
336 for name in filelist:
--> 337 if self.exists(name):
338 if self._isurl(name):
339 name = self._cache(name)
C:\Anaconda3\lib\site-packages\numpy\lib\_datasource.py in exists(self, path)
440
441 # Test local path
--> 442 if os.path.exists(path):
443 return True
444
C:\Anaconda3\lib\genericpath.py in exists(path)
17 """Test whether a path exists. Returns False for broken symbolic links"""
18 try:
---> 19 os.stat(path)
20 except OSError:
21 return False
ValueError: stat: embedded null character in path
它看起來像路徑中的錯誤。我100%確定txt在光盤c:路徑下。 請給予一些幫助。由於
嘗試着如果我離開了這樣的代碼在你的路徑,而不是反斜槓 –