Take user input and put it into a file in Python?

前端 未结 3 808
情歌与酒
情歌与酒 2020-12-11 09:00

I must have skipped a page or two by accident during my PDF Tutorials on Python commands and arguments, because I somehow cannot find a way to take user input and shove it i

3条回答
  •  隐瞒了意图╮
    2020-12-11 09:33

    Try Something Like This.

    #Getting Where To Save File
    where = raw_input('Where Do You Want To Save Your File? ')
    
    #Getting What To Write To File
    text = raw_input('What Do You Want To Write To Your File? ')
    
    #Actually Writing It
    saveFile = open(where, 'w')
    saveFile.write(text)
    saveFile.close()
    

提交回复
热议问题