获取此错误 我的输入文件是
def get_data_from_file(file_path=os.path.('C:/Users/anees/chatbot_data.txt')):
with open(file_path) as infile:
cleaned_lines = [line.strip() for line in infile if not line.startswith(('$$$', '###', '==='))]
return cleaned_lines
错误
C:\Users\anees\Anaconda3\envs\chatbot\python.exe C:/Users/anees/PycharmProjects/Web_analytics/Assignment1/knowlege_extraction.py
Traceback (most recent call last):
File "C:/Users/anees/PycharmProjects/Web_analytics/Assignment1/knowlege_extraction.py", line 245, in <module>
main()
File "C:/Users/anees/PycharmProjects/Web_analytics/Assignment1/knowlege_extraction.py", line 218, in main
triples = cl.extract_triples(sents)
File "C:\Users\anees\Anaconda3\envs\chatbot\lib\site-packages\pyclausie-0.1-py2.7.egg\pyclausie\SubprocessBackend.py", line 62, in extract_triples
stderr=subprocess.PIPE)
File "C:\Users\anees\Anaconda3\envs\chatbot\lib\subprocess.py", line 390, in __init__
errread, errwrite)
File "C:\Users\anees\Anaconda3\envs\chatbot\lib\subprocess.py", line 640, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Process finished with exit code 1
答案 0 :(得分:0)
尝试
os.path.join("Users","anees","chatbot_data.txt")
建立路径。
答案 1 :(得分:0)
如果你提供完整路径,那么不需要使用os.path.join()只需使用file_path,如下所示:
file_path=r'C:/Users/anees/chatbot_data.txt'
或者您可以按如下方式使用os.path.join()
:
os.path.join("Users","anees","chatbot_data.txt")