不确定为什么它不打印我的文本文件,即使我相信代码是正确的



每当我运行该程序时,它都会出现一个我不希望发生的错误。

我有一个文件名为"LogoArt",当我将其输入到输入中时,它说没有这样的文件或目录。

print('''You will have to enter a file name
Once the file name has been entered, the program will then print out your ASCII art''')
file_name = input('Enter file name: ')
with open(file_name) as file_handle:
    for line in file_handle:
        print(line)

我希望程序打印文本文档,但它说没有文件或目录。

    print('''You will have to enter a file name
    Once the file name has been entered, the program will then print out your ASCII art''')
    file_name = input('Enter file name: ')
    new_file = file_name + '.txt'
    with open(new_file_name) as file_handle:
       for line in file_handle:
            print(line)

相关内容

最新更新