PythonUtility class
Properties
-
hashCode
→ int
-
The hash code for this object.
no setteroverride
-
runtimeType
→ Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(Invocation invocation)
→ dynamic
-
Invoked when a nonexistent method or property is accessed.
inherited
-
toString()
→ String
-
A string representation of this object.
inherited
Static Methods
-
eval({required String code, List<(String, PyArgument)>? globals, List<(String, PyArgument)>? locals, required List<String> imports})
→ Future<String>
-
执行 Python 表达式,支持自定义 globals 和 locals 上下文
-
evalAsObject({required String code, List<(String, PyArgument)>? globals, List<(String, PyArgument)>? locals})
→ Future<PyObjectWrapper>
-
计算表达式并返回一个通用对象句柄 (PyObjectWrapper)
这允许 Dart 持有这个对象,并在随后调用它的方法
-
execute({required String code, List<(String, PyArgument)>? globals, List<(String, PyArgument)>? locals})
→ Future<void>
-
执行 Python 代码片段(无返回值)
适用于 import, class 定义, def 函数定义等
-
getModuleAttr({required String moduleName, required String attrName})
→ Future<String>
-
获取模块的属性
-
runFile({required String filePath})
→ Future<void>
-
运行一个 Python 脚本文件
-
setModuleAttr({required String moduleName, required String attrName, required PyArgument value})
→ Future<void>
-
设置模块的属性
对应 Python: module.attr = value