Oct-29-2017, 04:15 PM
(This post was last modified: Oct-29-2017, 07:54 PM by sparkz_alot.)
The problem starts when, from the terminal, as an example, the user cuts and pastes the following:
$thing1
thing2
thing3
thing4
...
When I open the user created file I want to see, as a column:
thing1
thing2
thing3
thing4
...
However, only the first line is accepted into the file. I know I'm using raw_input and it only accepts a single line...so how can I use the code for a user created file and somehow get multiple lines into that file?
I tried sys.stdin as well as trying to open targetfile as f but multi-line input won't get into the user created file.
There are no traceback errors.
#!/usr/bin/python
import os
#import sys
#user creates a file name
targetfile = raw_input('Enter Subject of email here: ')
things_list =
#if user enters input on multiple lines script doesn't send input to targetfilefound, it doesnt quit when type done either
things = raw_input("Enter things, then type 'done' on its own line to quit: \n")
while True:
try:
targetfilefound = open(targetfile , 'w')
targetfilefound.write(raw_input())
targetfilefound.close()
while things != "done":
things_list.append(things)
things = raw_input("")
things_list = ''.join(things_list)
except KeyboardInterrupt:
break
$thing1
thing2
thing3
thing4
...
When I open the user created file I want to see, as a column:
thing1
thing2
thing3
thing4
...
However, only the first line is accepted into the file. I know I'm using raw_input and it only accepts a single line...so how can I use the code for a user created file and somehow get multiple lines into that file?
I tried sys.stdin as well as trying to open targetfile as f but multi-line input won't get into the user created file.
There are no traceback errors.
#!/usr/bin/python
import os
#import sys
#user creates a file name
targetfile = raw_input('Enter Subject of email here: ')
things_list =
#if user enters input on multiple lines script doesn't send input to targetfilefound, it doesnt quit when type done either
things = raw_input("Enter things, then type 'done' on its own line to quit: \n")
while True:
try:
targetfilefound = open(targetfile , 'w')
targetfilefound.write(raw_input())
targetfilefound.close()
while things != "done":
things_list.append(things)
things = raw_input("")
things_list = ''.join(things_list)
except KeyboardInterrupt:
break