使用绝对路径,FileNotFoundError(Using absolute path, FileNotFoundError)
这应该是大声读取传递的文件。 当我为我正在阅读的任何文本文件传递绝对路径时,我得到一个FileNotFoundError。 适用于本地文件名。 有任何想法吗?
#!/usr/bin/env python3 from os import system def text_to_speech(word): system('say %s' % word) with open(input("Input File Path: ")) as fin: for line in fin: text_to_speech(line)
这是堆栈:
Traceback (most recent call last): File "timer.py", line 7, in <module> with open(input("Input File Path: ")) as fin: FileNotFoundError: [Errno 2] No such file or directory: '/Users/codeboy/Desktop/Project/test.txt '
This is supposed to read the passed file aloud. When I pass an absolute path for whatever text file I'm reading, I get a FileNotFoundError. Works fine for local filenames. Any ideas?
#!/usr/bin/env python3 from os import system def text_to_speech(word): system('say %s' % word) with open(input("Input File Path: ")) as fin: for line in fin: text_to_speech(line)
Here's the stack:
Traceback (most recent call last): File "timer.py", line 7, in <module> with open(input("Input File Path: ")) as fin: FileNotFoundError: [Errno 2] No such file or directory: '/Users/codeboy/Desktop/Project/test.txt '
原文:https://stackoverflow.com/questions/42866418
更新时间:2023-06-01 16:06