Passing arguments to Python

Depends what you mean by using sys.argv. I can call this script from the command line with an arguement or call the run() method directly from UiPath with the text argument. This is the python code:

import sys

def run(text):
    return " Hi " + text

if __name__ == "__main__":
    run(sys.argv[1])

and this is the invoke python activity to call the script:

image

The output is as expected, “Hi Bob”:
image

5 Likes