且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在python raw_input()函数中包含换行符?

更新时间:2023-02-09 10:48:49

可以使用 sys 模块吗?如果需要,这可以解决问题。只需按Ctrl-D即可结束。

Can you use the sys module? This will do the trick if you want. Just hit Ctrl-D to end it.

import sys
message = sys.stdin.readlines()

否则,这会回答您的问题: Python raw_input忽略换行符

Otherwise, this answers your question: Python raw_input ignore newline