Hi Team,
i am trying to invoke a method from python and print the result in UiPath but instead of result the following is getting as following: UiPath.Python.PythonObject
can anyone help what exactly needs to be fixed
Hi Team,
i am trying to invoke a method from python and print the result in UiPath but instead of result the following is getting as following: UiPath.Python.PythonObject
can anyone help what exactly needs to be fixed
Hello Sai,
Code : # Original Python code returning some object
def your_python_function():
result = some_operation()
return result
def your_python_function():
result = some_operation()
result_str = str(result)
return result_str
In this modified code, result
is converted to a string using the str()
function before it is returned. This ensures that the output of your Python function is a string data type, which UiPath can handle for printing.
Replace some_operation()
with the actual code that produces the result you want to convert to a string.
Once you’ve made this modification to your Python code, you can invoke this function from UiPath, and the result will be a string that you can print or manipulate as needed within your UiPath workflow.
Also Please check :
Thank you
Please let me if your issue resolve.
Happy automation.
i changed something like this, but still same error… in python i am able to print the result, but not getting result in UiPath
Hi @devasaiprasad_K ,
Use “Get Python Object” Activity: This activity is used to get the .NET data type from a Python object. It can only be used inside the Python Scope activity.
Refer to my attached test workflow. I hope this helps you.
Main.xaml (9.4 KB)
Python code:
import sys
def add_numbers(num1, num2):
return num1 + num2
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python script.py <num1> <num2>")
else:
try:
num1 = float(sys.argv[1])
num2 = float(sys.argv[2])
result = add_numbers(num1, num2)
print("The sum is", result)
except ValueError:
print("Invalid input. Please provide valid numbers.")
Regards,
Vinit Mhatre