raw_input accepts any input up until a new line character is entered.

The easiest way to do what you are asking it to accept more entries, until an end of file is encountered.

print("please copy and paste your charge discharge data.\n"
      "To end recording Press Ctrl+d on Linux/Mac on Crtl+z on Windows")
lines = []
try:
    while True:
        lines.append(raw_input())
except EOFError:
    pass
lines = "\n".join(lines)

Then do something with the whole batch of text.

Answer from user764357 on Stack Overflow
🌐
Reddit
reddit.com › r/learnpython › pasting multiple lines as input
r/learnpython on Reddit: Pasting multiple lines as input
January 11, 2022 -

Hi, im making a text sorter, but i want to be able to copy and paste multiple lines of text into the input, so:

firstname, lastname

firstname2, lastname2

firstname3, lastname3

.....

i print it out after it runs, and its blank

filename = (list)(input("List: \33[37m"))

textFile = open("Names.txt", "w")for line in filename:textFile.write(filename[line])textFile = open("Names.txt", "r")print(textFile.read())

is there any way to do this? i need to get that list of names to be able to be converted to a text file so I can do things with it

Edit: for clarification, I want to be able to do multiple lines with one copy/paste. and the way that the text is currently formatted, it doesn’t have \n included after the end of each line.

I am given a large text document full of names, and I need to copy paste them in and organize them from there

EDIT 2: SOLUTION FOUND

I found this on the internet, and it worked perfectly for me!! https://www.csestack.org/multiline-user-input-in-python/

Discussions

Copy/pasting: multiline in a single line prompt
Could we have an option so that prompt only accepts a single line, even when pasting some text ? Currently, even when multiline is set to False, you can paste multi-line text in it. Code: Here'... More on github.com
🌐 github.com
11
June 30, 2017
Allow pasting multiple lines in the Python Console
It is currently impossible to paste more than one line in the python console. It would be handy if this could be possible, as it will make copying and testing code from the console easier. I think we should make the input control multi line as well, however it should of course keep the navigable ... More on github.com
🌐 github.com
2
June 19, 2019
string - Multiple lines user input in command-line Python application - Stack Overflow
What I would like to achieve is to allow user pasting whole text (containing multiple lines) and capture the input as one string in entirely command-line tool. Is it possible in Python? More on stackoverflow.com
🌐 stackoverflow.com
[Feature] Be able to paste multiple lines at once at the >>> prompt
I'd like to be able to select these lines, copy them via Ctrl+c, move input focus to the PythonScript console window's >>> prompt box, and paste via Ctrl+v, with the intention that when I press Enter after that, all three of these lines would be executed, one after the other. More on github.com
🌐 github.com
4
November 13, 2024
🌐
GitHub
github.com › prompt-toolkit › python-prompt-toolkit › issues › 519
Copy/pasting: multiline in a single line prompt · Issue #519 · prompt-toolkit/python-prompt-toolkit
June 30, 2017 - Could we have an option so that prompt only accepts a single line, even when pasting some text ? Currently, even when multiline is set to False, you can paste multi-line text in it. Code: Here's the code i am using: PROMPT_TOOLKIT_HISTOR...
Author   gpotter2
🌐
Python Forum
python-forum.io › thread-31517.html
How to paste several lines of codes to the Python console
I'm not sure in which part of the forum to post this (as this is not really code related). I used to be able to do this until very recently. Now when I try to paste several lines at once I get the error message: Quote:SyntaxError: multiple statement...
🌐
Python
bugs.python.org › issue20058
Issue 20058: IDLE's shell returns a multiple-line string to input() or readline() when multiple lines of text are pasted by the user - Python tracker
December 23, 2013 - This issue tracker has been migrated to GitHub, and is currently read-only. For more information, see the GitHub FAQs in the Python's Developer Guide · This issue has been migrated to GitHub: https://github.com/python/cpython/issues/64257
🌐
GitHub
github.com › nvaccess › nvda › issues › 9776
Allow pasting multiple lines in the Python Console · Issue #9776 · nvaccess/nvda
June 19, 2019 - It is currently impossible to paste more than one line in the python console. It would be handy if this could be possible, as it will make copying and testing code from the console easier.
Author   LeonarddeR
Find elsewhere
🌐
Python
bugs.python.org › issue43379
Issue 43379: Pasting multiple lines in the REPL is broken since 3.9 - Python tracker
This issue tracker has been migrated to GitHub, and is currently read-only. For more information, see the GitHub FAQs in the Python's Developer Guide · This issue has been migrated to GitHub: https://github.com/python/cpython/issues/87545
🌐
GitHub
github.com › bruderstein › PythonScript › issues › 353
[Feature] Be able to paste multiple lines at once at the >>> prompt · Issue #353 · bruderstein/PythonScript
November 13, 2024 - Consider these lines of text in a Notepad++ tab: a=3 b=4 c=5 I'd like to be able to select these lines, copy them via Ctrl+c, move input focus to the PythonScript console window's >>> prompt box, and paste via Ctrl+v, with the intention ...
Author   alankilborn
🌐
IPython
ipython.org › ipython-doc › dev › interactive › reference.html
IPython reference — IPython 3.2.1 documentation
If you want to paste multiple lines in the terminal, it is recommended that you use %paste. All these features are based on the GNU readline library, which has an extremely customizable interface. Normally, readline is configured via a .inputrc file.
🌐
DaniWeb
daniweb.com › programming › software-development › threads › 269208 › raw-input-and-multiple-lines
python - raw_input and multiple lines | DaniWeb
March 20, 2010 - That is why your single raw_input() only ever sees line 1. This is not something you can change by "using Enter"; the newline is exactly what ends raw_input(). If you want a paste that can contain any character (including \, quotes, semicolons, etc.), the simplest CLI pattern is to read until EOF. EOF is a keystroke, not a character in the data, so it will never collide with your content. # Python 2 import sys print "Paste your text, then press Ctrl-D (Unix/Mac) or Ctrl-Z, Enter (Windows)." data = sys.stdin.read() print "Read %d bytes" % len(data) # do something with 'data'
🌐
Bobby Hadz
bobbyhadz.com › blog › python-input-multiple-lines
Multiple lines user Input in Python | bobbyhadz
Copied!lines = [] while True: try: lines.append(input()) except EOFError: lines_str = '\n'.join(lines) print(lines_str) break print(lines) ... We used a while loop to iterate until EOF. If the user presses CTRL + D (Unix) or CTRL + Z (Windows), an EOFError exception is raised and is handled in the except block. The break statement breaks out of the innermost enclosing for or while loop. You can learn more about the related topics by checking out the following tutorials: Taking user input boolean (True/False) values in Python
🌐
Python Data Science Handbook
jakevdp.github.io › PythonDataScienceHandbook › 01.03-magic-commands.html
IPython Magic Commands | Python Data Science Handbook
In the direct paste, the interpreter is confused by the additional prompt characters. But never fear–IPython's %paste magic function is designed to handle this exact type of multi-line, marked-up input: In [3]: %paste >>> def donothing(x): ...
🌐
Ask Ubuntu
askubuntu.com › questions › 1315046 › enable-multi-line-paste-for-conda-python-shell-on-18-04
Enable multi-line paste for conda python shell on 18.04 - Ask Ubuntu
In the conda environment the code seems to be pasted in bracketed mode raising an error: $ python Python 3.8.5 (default, Sep 4 2020, 07:30:14) [GCC 7.3.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information. >>> import numpy as np import pandas as pd File "<stdin>", line 1 import pandas as pd ^ SyntaxError: multiple ...
🌐
Automate the Boring Stuff
automatetheboringstuff.com › 1e › chapter6
Chapter 6 – Manipulating Strings
If we used the “List of Lists ... by author abbreviation\nLists of cultivars' The \n newline characters in this string cause it to be displayed with multiple lines when it is printed or pasted from the clipboard....
🌐
Automate the Boring Stuff
automatetheboringstuff.com › chapter6
Automate the Boring Stuff with Python
If we used the “List of Lists ... by author abbreviation\nLists of cultivars' The \n newline characters in this string cause it to be displayed with multiple lines when it is printed or pasted from the clipboard....
🌐
Reddit
reddit.com › r/learnpython › multi-line input in python 3
r/learnpython on Reddit: Multi-line input in Python 3
June 15, 2019 -

I'm trying to feed a prompt to a GPT-2 model, which is trained on song lyrics. With this model, you can feed it a prompt and it will attempt to finish it. The problem I'm having is that I need for the prompt to be formatted correctly like song lyrics - with each lyric on a newline. Since this model has been trained on formatted lyrics, the prompt needs to look the same to produce above average results.

input() doesn't work, because hitting return submits the text. I've also tried sys.stdin.read() as well and nothing seems to happen, just returns ' '.

Is it because I'm running it in a notebook? I'm only like 8 months deep into this python hobby, so I could be asking for something that can't happen.

Here's the code, would appreciate any ideas you've got.

prompt = input('Input Prompt:')
gpt2.generate(sess,
              length=200,
              temperature=.99,
              prefix= prompt, #this is where the prompt goes
              nsamples=5,
              top_p=.9,
              batch_size=5,
              run_name='run1'
              )