"ANKUR AGGARWAL" <coolankur2...@gmail.com> wrote
Hey- suppose we have a file name-"my file number"
if we want to execute it into the terminal it would be like - my\
file\
number
It depends what you are trying to do.
so wondering is there any one in the python that change the enter
string
into the terminal string one- like if user enter the file name with
path- "my file number". i want to automatically convert it into "my\
file\ number"
If you use raw_input to capture the filename then the escaping will be
done
for you when you come to use it.
s = raw_input('?')
?name with spaces
s
'name with spaces'
f = open(s,'w')
f.write('hello world\n')
f.close()
f = open(s)
f.read()
'hello world\n'
f.close()
^Z
C:\Documents and Settings\Alan Gauld>dir n*
Volume in drive C is SYSTEM
Volume Serial Number is 7438-BB1D
Directory of C:\Documents and Settings\Alan Gauld
13/08/2010 09:03 13 name with spaces
So are you sure you need to do this?
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor