Multiple lines user input in command-line Python application

前端 未结 3 1285
清歌不尽
清歌不尽 2021-01-05 13:30

Is there any easy way to handle multiple lines user input in command-line Python application?

I was looking for an answer without any result, becaus

3条回答
  •  走了就别回头了
    2021-01-05 14:22

    You could get the text from clipboard without any additional actions which raw_input() requires from a user to paste the multiline text:

    import Tkinter
    root = Tkinter.Tk()
    root.withdraw()
    
    text = root.clipboard_get()
    
    root.destroy()
    

    See also How do I copy a string to the clipboard on Windows using Python?

提交回复
热议问题