UiPath Documentation
activities
latest
false

开发者活动

上次更新日期 2026年4月21日

加载 Python 脚本

UiPath.Python.Activities.LoadScript

使您能够将 Python 脚本的处理程序存储在 PythonObject 变量中。

您可以使用生成的变量来调用代码中的方法。如果除脚本中存在的方法外还存在内联代码,则系统也会在运行时执行这些代码。

只能在“Python 作用域”活动中使用。

出于软件限制,默认情况下,此活动使用 Python 活动包的安装位置作为脚本的运行目录。

为了能够在脚本中使用相对路径,您可以将以下代码添加到加载的脚本中:

import sys 
            import os
            sys.path.append(os.path.dirname(os.path.realpath(<em>file</em>)))
            import <your module here>
import sys 
            import os
            sys.path.append(os.path.dirname(os.path.realpath(<em>file</em>)))
            import <your module here>

属性

常见
  • DisplayName - The display name of the activity. This field supports only String variables.
输入
  • Code - The Python code that you want to load. This field supports only String variables.
  • File - The path to the file which contains the Python code that you want to load. This field supports only String variables.
其他
  • “私有”- 选中后将不再以“Verbose”级别记录变量和参数的值。
输出
  • “结果”- 此为指定 Python 脚本的处理程序,存储在“PythonObject”变量中。
  • 属性

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新