python中用input输入时可以回车换行(转帖)
原帖地址:https://www.cnblogs.com/zlong123/p/10427519.html
#实现回车换行,而不是结束
endstr="end"#重新定义结束符
str=""
for line in iter(input,endstr):#每行接收的东西 用了iter的哨兵模式
str+= line+"\n"#换行
print(str)
原帖地址:https://www.cnblogs.com/zlong123/p/10427519.html
#实现回车换行,而不是结束
endstr="end"#重新定义结束符
str=""
for line in iter(input,endstr):#每行接收的东西 用了iter的哨兵模式
str+= line+"\n"#换行
print(str)