Python - Create File object using absolute path

Description

Create File object using absolute path

Demo

print( open(r'C:\Python36-32\main.py').readline() )
print( open('C:/Python36-32/main.py').readline() )
print( open('C:\\Python36-32\\main.py').readline() )

The raw string form in the second command is useful to turn off accidental escapes when you can't control string content.

Related Topic