try: file = input('enter the file :') with open(file, 'r') as f: data = f.read() print(data)except FileNotFoundError:print(f'the file {file} does not exists:')
打开windows的cmd运行程序,效果如下:
京公网安备 11010502049817号