How do I read multiple lines of raw input in Python?

后端 未结 9 1526
礼貌的吻别
礼貌的吻别 2020-11-22 09:28

I want to create a Python program which takes in multiple lines of user input. For example:

This is a multilined inp         


        
9条回答
  •  时光取名叫无心
    2020-11-22 10:09

    sys.stdin.read() can be used to take multiline input from user. For example

    >>> import sys
    >>> data = sys.stdin.read()
      line one
      line two
      line three
      <>
    >>> for line in data.split(sep='\n'):
      print(line)
    
    o/p:line one
        line two
        line three
    

提交回复
热议问题