how to pass the string with spaces? My sample program is passing the string and getting substring its working fine if I pass string without spaces but when passing with spaces showing error.
If you want to pass named string arguments containing spaces in between to the python script, you can simply put the text in double quotes.
Example if you’re using argparse-
File Name - example.py
if __name__ == “__main__”:
parser = argparse.ArgumentParser(“Print String”)
parser.add_argument(’–input1’,’-i1’,type=str,help=“Manadatory Parameter”, required=True)
args = parser.parse_args()
Call this script by -
example.py -i1 “Hello World”
example.py --input1 “Hello World”
I have already done this and its working fine in IDE but not working in assistedge.
You need to ensure that when you’re passing the input from arguments, the input should also contain double quotes.
You can achieve this by creating the argument with value -
Here three double quotes are used in end and start to escape the double quotes.
Its working after using triple quotes. Thank you
In case your input argument value is defined during run time, for example it is stored in some other argument, then you’ll have t form the input in below way -
inputArgument = “”""+argumentStoringValue+""""