I want to write a code to read a input from user that include newline(enter key) Something like :
begin west north
north east east south
east end
and when I press enter , do something for example :
line = 0
if input=='\n':
line = 1
How can I do it!?
CodePudding user response:
I don't think folks really grasp what he was after. Most of the time, he wants to input and act on a single line. But if he types "begin", then he wants to accumulate until the user enters a blank line. This does that:
def getinput():
start = input(">> ")
if 'begin' in start:
while 1:
line = input(" > ")
if not line:
break
start = line
return start
print(getinput())
CodePudding user response:
obviously no one here knows exactly its purpose, but how can you do this with the help of a loop?
while 1:
if input():
print("\n")
As long as there is an input, the value of the input will be equal to == enter, as I said, nobody knows what to do, but this is it.
With the help of the module
import pyautogui
pyautogui.press('enter')
Have a good day.
CodePudding user response:
Try this
'''python
Lines_string = [] #save all lines write for user
#add line in list (lines_string)
While true:
Line = input() #get user writing
if Line == "[exit]":
Break #break loop
else:
Lines_string.append(Line) # save line in the list
#read list
for line, data in enumerator(Lines_string):
# save data in file text for example
'''
in framework is for example
#pyside6 is
inputText.PressedReturn.connect(method)
Sorry for my english :'c
if you want only read line and print try this
while True: #infinite loop
line = input() #read data user writeing