Very basic Python question (strings, formats and escapes)

后端 未结 10 2279
别那么骄傲
别那么骄傲 2021-02-06 10:59

I am starting to learn Python with an online guide, and I just did an exercise that required me to write this script:

from sys import argv

script, filename = ar         


        
10条回答
  •  长发绾君心
    2021-02-06 11:57

    I think the intent was for the student to leverage what had been taught in previous lessons and arrive at the following as a solution:

    print "Now I'm going to ask you for three lines."
    
    line1 = raw_input("line 1: ")
    line2 = raw_input("line 2: ")
    line3 = raw_input("line 3: ")
    
    print "I'm going to write these to the file."
    
    target.write(line1 + '\n' + line2 + '\n' + line3 + '\n')
    
    print "And finally, we close it."
    target.close()
    

提交回复
热议问题