I can read files like this (relative path):

with open("Testfile_B.txt") as file_object:
    contents = file_object.read()
    print(contents)

But how do I read files if I want to specify the location (absolute path):

file_path = "C:\Users\Rafael\Testfile.txt"
with open(file_path) as file_object:
    contents = file_object.read()
    print(contents)

The above does not work ...
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to