我正在使用以下代码:
@H_404_5@#!/usr/bin/env python
import sys
from io import StringIO
#data = sys.stdin.readlines()
sys.stdin = """
hello I feel good
how are you?
where have you been?
"""
for line in sys.stdin:
print line
当我运行上述代码时,打印行将打印出分配给sys.stdin的文本的每个字符.每行打印一个字符:
@H_404_5@h
e
l
l
o
I
....truncated
我正在尝试将输出保存在sys.stdin中,它应如下所示:
@H_404_5@hello I feel good
how are you?
where have you been?
最佳答案