Replacing a text with \n in it, with a real \n output

前端 未结 3 1539
情话喂你
情话喂你 2021-01-04 20:00

I am trying to get a config from a juniper router and I have the following problem:

After setting this

stdin, stdout, stderr = client1.exec_command(\         


        
3条回答
  •  轮回少年
    2021-01-04 20:51

    An alternative to what you want is splitting your string into a list of strings (per line).

    mystr = 'a\nb\nc'
    mystr = mystr.split(sep='\n')
    print(mystr)
    #this will be your print output:['a', 'b', 'c']
    for s in mystr:
        print(s)
    #your print output:
    #a
    #b
    #c
    

提交回复
热议问题