将段落缩进写入文本文件

时间:2019-05-01 20:45:30

标签: python-3.x with-statement

这很简单(我认为),但是我却找不到如何做。我只需要在文本文件中附加新的短语,但是每个新的附加在新段落中。

Ex输出:

代替:第一个短语,第二个短语和第三个短语。

以这种方式编写:

第一个短语

第二个短语

第三个短语

这是我的代码:

nm = 'name'
while nm != 'done' :
    nm = str(input('name : '))
    pos = str(input('%s ocupation : ' %(nm)))
    with open("Output.txt", "a") as fd:
        fd.write('%s = irmaos("%s","%s" )' % (nm, pos, nm))

0 个答案:

没有答案