Here is the code that I welded to a simple open (), the Open file input instruction is displayed, but the Close file does not work. This is done in the Idle interface, but not in the command line interface.
Both the program and the file (spelled correctly and all lowercase letters) are on the desktop for this test. Does anyone see what is missing? Open
input("\n\nPress the enter key to Open file")
print("Opening and closing the file.")
text_file = open("nicole1.txt", "r")
input("\n\nPress the enter key to Close file")
text_file.close()
input("\n\nPress the enter key to exit.")
** Update, Ok, I tried the absolute path, and it was not successful. I have a copy of this file on a flash drive. I ran it in a Windows XP window and in a Windows 7 window, and everything went fine. I take the same flash drive and try to run it in the Windows10 Box, and I had a problem. One comment asked if there is a trace and there is, and this basically indicates that the file does not exist. Now I’m trying to determine if this is a Windows 10 problem. In addition, the code will work in standby mode on both Windows mailboxes (XP and Win10).
source
share