我的代码如下所示:

fileName = "interview.txt"
accessMode = "r"
interview = open(fileName, accessMode)

name = interview.readline()
age = interview.readline()
colour = interview.readline()
print("Hello, "+name+" who is "+age+" years old and who's favourite colour is "+colour+".")


我要说的是:您好,*名字*,*年龄*岁,最喜欢的颜色是*颜色*。相反,由于在记录信息时(从不同的python程序中)必须将信息放在不同的行上,因此我在后面加上了\ n。因此输出之后会有一个回车,如下所示:

 Hello, *Name*
 who is *age*
 years old and who's favourite colour is *colour*.

最佳答案

readline输出上的呼叫条:

interview.readline().strip()

09-05 01:43