This seems like it should be very easy:
f = open(\'C:\\Users\\john\\Desktop\\text.txt\', \'r\')
But I am getting this error:
Your file name has backslash characters in it. Backslash is the escape character in Python strings. Either replace them with '/' characters or use r'C:\Users\john\Desktop\text.txt'.
'/'
r'C:\Users\john\Desktop\text.txt'
You might also find the functions in os.path useful.