使用文件功能时出现错误信息

时间:2020-10-01 12:27:34

标签: python txt

这是怎么回事?我尝试在函数中读取我的txt文件。:

def vragen_ophalen():
    text_file = open("vragen.txt", "r")
    print(text_file.read())



def main():
    vragen_ophalen()

if __name__ == "__main__":
    main()  

错误消息:

Traceback (most recent call last):
  File "/Users/buni/Desktop/Leiden/iipr/Huiswerk python/sorteerhoed_concept.py", line 11, in <module>
    main()  
  File "/Users/buni/Desktop/Leiden/iipr/Huiswerk python/sorteerhoed_concept.py", line 8, in main
    vragen_ophalen()
  File "/Users/buni/Desktop/Leiden/iipr/Huiswerk python/sorteerhoed_concept.py", line 2, in vragen_ophalen
    text_file = open("vragen.txt", "r")
FileNotFoundError: [Errno 2] No such file or directory: 'vragen.txt'

0 个答案:

没有答案