我正在编写代码以读取两个文本文件,并打印第一个文件中每一行的输出以及文件2上的所有行
try:
with open("file1.txt", "r") as ins , open("file2.txt", "r") as ins2 :
array = []
for line in ins:
#print(line)
# Start inner for
for line2 in ins2:
print(line + " : " + line2)
except IOError as e:
print 'Operation failed: %s' % e.strerror
提交1个内容样本:
text1
text2
text3
文件2内容样本:
1985
1986
1987
输出必须为
text1 :1985
text1 :1986
text1 :1987
text2 :1985
text2 :1986
.
.
.
.