First create a new exercise7_2.txt file
Then analyze step by step
It should be noted that str() should be added to the content to be written into the file in f.write(), otherwise an error will be prompted
with open('f:\\exercise7_2.txt','r+') as f:
s=input("请输入一个字符串")
f.write("输入的字符串是:" + str(s) +"\n"+ "字符串的长度是:" + str(len(s)))
f.close()