Why Python language does not have a writeln() method?

前端 未结 5 496
情话喂你
情话喂你 2020-12-30 23:47

If we need to write a new line to a file we have to code:

file_output.write(\'Fooo line \\n\')

Are there any reasons why Python does not ha

5条回答
  •  死守一世寂寞
    2020-12-31 00:28

    In Python 2, use:

    print >>file_output, 'Fooo line '
    

    In Python 3, use:

    print('Fooo line ', file=file_output)
    

提交回复
热议问题