python中没有这样的文件或目录错误

时间:2016-11-03 03:15:07

标签: python-2.7 ipython filepath

在我的python研究中,我遇到了这样的问题:

 File "wfdbtools.py", line 418, in _getheaderlines
 all_lines = open(hfile, 'r').readlines()

IOError: [Errno 2] No such file or directory: 'C:\\Users\\liujiankang\\Desktop\\\xe7\xa8\x8b\xe5\xba\x8f-1\\datafile\x03908522m\x03908522m_ECG.txt.hea'

对应代码:

def check_qrs_detection():
from wfdbtools import rdsamp, rdann
import subprocess
test_record = 'C:\Users\liujiankang\Desktop\程序-1\datafile\3908522m\3908522m_ECG.txt'
qrslead = 2

data, info = rdsamp(test_record)

qrsdetector = QRSDetector(data, info['samp_freq'])

qrspeaks = qrsdetector.qrs_detect(qrslead)
print 'Found %s QRS complexes' %(len(qrspeaks))
qrsdetector.write_ann(os.path.abspath(test_record) + '.test')

ref_qrs = rdann(os.path.abspath(test_record), 'atr')
print ref_qrs.shape
print qrspeaks[:10]
print ref_qrs[:10, :1]
sigdata = data[:, qrslead]
pylab.plot(sigdata)
for r in qrspeaks:
    pylab.plot(r, sigdata[r], 'xr')
for r in ref_qrs[:, 1]:
    pylab.plot(r*info['samp_freq'], sigdata[r*info['samp_freq']], 'ob')
pylab.show()

if __name__ == '__main__':
check_qrs_detection()
test()

由于代码是从其他人复制的,我怀疑的原始路径如下:

test_record = '../samples/format212/100'`

可能是什么问题?谢谢!

0 个答案:

没有答案