writing integer values to a file using out.write()

前端 未结 4 654
忘了有多久
忘了有多久 2021-02-05 04:48

I am generating some numbers(lets say, num) and writing the numbers to output file using outf.write(num).
But compiler is throwing an error:

         


        
4条回答
  •  故里飘歌
    2021-02-05 05:14

    any of these should work

    outf.write("%s" % num)
    
    outf.write(str(num))
    
    print >> outf, num
    

提交回复
热议问题