Hi I am trying to represent a file location as a variable because the finial script will be run on another machine. This is the code I have tried followed by the error I get. It seems to me that some how python is adding “\” and that is causing the problem. If that is the case how do I get it not to insert the “\”? Thank you
F = 'C:\Documents and Settings\myfile.txt','r'
f = open(F)
and the error
TypeError: invalid file: ('C:\\Documents and Settings\\myfile.txt', 'r')
Try
Instead of using the variable F. the way you have it
'r'is part of the file name, which it is not.