By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,768 Members | 2,004 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,768 IT Pros & Developers. It's quick & easy.

Create new text file

P: 3
hi, noobie here at python
heres the question. "The name of the file should be accepted as user input"
May 22 '07 #1
Share this Question
Share on Google+
4 Replies


ilikepython
Expert 100+
P: 844
hi, noobie here at python
heres the question. "The name of the file should be accepted as user input"
Ok...
Have you tried to start that?
May 22 '07 #2

P: 3
oye
?? like wat i mean is wen the user enters sumthin with the raw_input command i then need to get that answer from raw_input and save the raw_input answer as a text file as the saved filename.
May 22 '07 #3

dshimer
Expert 100+
P: 136
At the very simplest level you may want something like.
Expand|Select|Wrap|Line Numbers
  1. >>> name=raw_input('Filename?')
  2. >>> openfile=open(name,'w')
  3. >>> openfile.write('something to put in the file')
  4. >>> openfile.close()
  5.  
'w' is opening in write mode
May 22 '07 #4

P: 3
oye
thanks exactly what i wanted.thankyou again
May 22 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.