Oh yes, thanks. That worked. :)
On 27 March 2013 21:58, Bod Soutar <bod...@googlemail.com> wrote: > You were opening the file for reading, rather than writing. It > therefore was expecting to find a file. > Change > fo = open('fname','r+') > to > fo = open('fname','w') > > Bodsda > > On 27 March 2013 16:17, Sayan Chatterjee <sayanchatter...@gmail.com> > wrote: > > for t in range(0,200): > > fname = 'file_' + str(t) > > > > So it will assign fname values file_0, file_1 so on. Dropping the quotes > is > > giving me > > > > IOError: [Errno 2] No such file or directory: 'file_0' > > > > > > Indeed the file is not present. In C we write,if we have to record data > in a > > file > > > > FILE *fp > > > > fp = fopen("file.dat","w") > > > > > > Here I want to write different data sets in files having different name > i.e > > I want to create the files with the data sets. I am quite new to Python, > so > > you can assume zero knowledge while answering. Thanks for your support. > :) > > > > > > On 27 March 2013 21:38, Walter Prins <wpr...@gmail.com> wrote: > >> > >> Hello, > >> > >> On 27 March 2013 15:59, Sayan Chatterjee <sayanchatter...@gmail.com> > >> wrote: > >>> > >>> Hi Amit, > >>> > >>> fo = fopen('fname','r+') > >>> fo.write("%d %d",j,counter) > >>> > >>> > >>> Is giving the following error: > >>> > >>> File "ZA.py", line 30, in <module> > >>> fo = open('fname','r+') > >>> IOError: [Errno 2] No such file or directory: 'fname' > >>> > >>> Where is the mistake? > >> > >> > >> You are trying to open a file named literally "fname" due to putting it > in > >> quotes, you probably want to drop the quotes. > >> > >> Walter > > > > > > > > > > -- > > > > > > > -------------------------------------------------------------------------- > > Sayan Chatterjee > > Dept. of Physics and Meteorology > > IIT Kharagpur > > Lal Bahadur Shastry Hall of Residence > > Room AB 205 > > Mob: +91 9874513565 > > blog: www.blissprofound.blogspot.com > > > > Volunteer , Padakshep > > www.padakshep.org > > > > _______________________________________________ > > Tutor maillist - Tutor@python.org > > To unsubscribe or change subscription options: > > http://mail.python.org/mailman/listinfo/tutor > > > -- -------------------------------------------------------------------------- *Sayan Chatterjee* Dept. of Physics and Meteorology IIT Kharagpur Lal Bahadur Shastry Hall of Residence Room AB 205 Mob: +91 9874513565 blog: www.blissprofound.blogspot.com Volunteer , Padakshep www.padakshep.org
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor