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

前端 未结 4 682
忘了有多久
忘了有多久 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:29

    i = Your_int_value
    

    Write bytes value like this for example:

    the_file.write(i.to_bytes(2,"little"))
    

    Depend of you int value size and the bit order your prefer

提交回复
热议问题