因此,当我尝试打印Python函数function.__doc__
的帮助/信息时,在文档字符串中出现\n
时,控制台输出而不是打印新行,打印\n
。任何人都可以帮助我禁用/帮助与此?python newline display in console
这是我的输出:
'divmod(x, y) -> (div, mod)\n\nReturn the tuple ((x-x%y)/y, x%y). Invariant: div*y + mod == x.'
我想输出是:
'divmod(x, y) -> (div, mod)
Return the tuple ((x-x%y)/y, x%y). Invariant: div*y + mod == x.'
P.S:我已经试过这在OS X,Ubuntu的使用Python 2.7。
是。所以根据我的理解,为了'unsee''\ n',我应该使用print来代替只输入[function] .__ doc__? – armundle
是的。它也会放弃报价。 –