You create raw string from a string this way:
test_file=open(r'c:\Python27\test.txt','r')
How do you create a raw variable from a string variable, such as
path = 'c:\Python27\test.txt'
test_file=open(rpath,'r')
Because I have a file path:
file_path = "C:\Users\b_zz\Desktop\my_file"
When I do:
data_list = open(os.path.expandvars(file_path),"r").readlines()
I get:
Traceback (most recent call last):
File "<pyshell#32>", line 1, in <module>
scheduled_data_list = open(os.path.expandvars(file_path),"r").readlines()
IOError: [Errno 22] invalid mode ('r') or filename: 'C:\\Users\x08_zz\\Desktop\\my_file'
r"C:\Users\b_zz\Desktop\my_file"
in the first place? Or better yet,"C:/Users/b_zz/Desktop/my_file"
? – Mountain