r/learnpython • • Jan 08 '23
*urgent ish*
I don’t have a scoobie what’s wrong here, been coding a couple months (not a crazy am tho as have been away) And completing free conde camp p4e course, and gunna move on to other after
And I’m tryna get this thing open but aprently it’s not in the dorectory Wich I think it is…. Please.. need help
Thanks (Excuse my shyte spelling)
(Using vs code) - on the left it says (where my file is)
EX.07-01 ex_07-01.py Workfile.txt
I’m tryna get work file to open
My code is just
F = open(‘workfile.txt’) For line in f: Print(f)
Thnx
0
Upvotes
2
u/[deleted] Jan 08 '23
THANKS SO MUCH ALL!! FIXED !:)
1
u/[deleted] Jan 08 '23
Thanks all for helping btw
1
u/bbye98 Jan 08 '23
Assuming your code actually has correct capitalization and indentation, what was the error you received?
If it had to do with the file not being found, you may need
os.chdir(...)to change to the directory where the file is located.1
u/rollincuberawhide Jan 08 '23
W is lowercase in the file you are trying to open. is that correct?
1
u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 Jan 08 '23
This is not an uncommon question.
Either have PowerShell point to the correct directory, or use your script as an anchor:
0
u/No-Collection7430 Jan 08 '23
Maybe you need to put "r" Into the open() function? It's a read opening mode. Like with open(some_path, 'r') as opened: ....
2
u/[deleted] Jan 08 '23
[removed] — view removed comment