Closed P4UL-M closed 4 years ago
Well i kept looking for a way around the problem, i thought i found after seeing that by executing the code in python 2.7 it worked with input () but in it works only when the input is a number otherwise i gets a NameError: name 'mytext' is not defined
orInvalid syntaxt
if i add a space. I also try to create a file with echo
and then access it with python but the command return nothing so it wait the time out and stop.
I will keep search but if you have a solution that could be great.
In Python 2, the input
function actually evaluates the input as Python code (see here). So, you should use the raw_input
function instead to get a string.
As for the input though, unfortunately I tried but I could not get any input on Python 3. :(
I tried some other methods, and this seems the best:
It is much easier to pass input as the command itself, and then use sys.argv
to access the data (do import sys.argv
first).
EDIT: Make sure your data is surrounded with quotation marks ("
) so that the data appears as a single string.
What does this do?
Sent from Yahoo Mail for iPhone
On Tuesday, June 16, 2020, 7:49 PM, Ong Yong Xin notifications@github.com wrote:
I tried some other methods, and this seems the best:
It is much easier to pass input as the command itself, and then use sys.argv to access the data (do import sys.argv first).
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Thank you, for Python2
, I didn't know that there was a different function for string
and int
it can still be good to know. Sys.argv
seems to be the better way, at least that work better than i hoped be able to do. Now i can finish my script !
Hey,
I already see the two issues on the subject but i didn't understand how we are supposed to access the input fiel of Shortcut with a python script.
I want to execute a script with Shorcut on my phone. For this I have a script who i execute with the command
python test2.py
in the cd$SHAREDDIR
. I want to add an input to this script so i add one in the input field below but I can't access it. I try to use a classicmyvariable = input()
but it return an EOFError ( If i understand that say that there is no input), I also try with asys.stdin.read(i)
and... .readlines(i)
but it give me a null result. I also try withfileinput.input()
and no more result.How should I access to this input, can they be use like that or is there another way to do what i want ?