Closed he426100 closed 11 months ago
原理 python的内置函数是通过 import builtins导入的,用 PyCore::import('builtins')后就可以调用任何函数了
import builtins
示例
<?php
class MyPy extends PyCore { protected static $py;
public static function instance() { if (!self::$py) { self::$py = self::import('builtins'); } return self::$py; }
public static function dump($e) { var_dump(self::scalar($e)); }
public static function __callStatic($name, $arguments) { return self::instance()->$name(...$arguments); }
}
MyPy::dump(MyPy::range(1, 10, 2)) array(5) { [0]=> int(1) [1]=> int(3) [2]=> int(5) [3]=> int(7) [4]=> int(9) }
原理 python的内置函数是通过
import builtins
导入的,用 PyCore::import('builtins')后就可以调用任何函数了示例
class MyPy extends PyCore { protected static $py;
public static function dump($e) { var_dump(self::scalar($e)); }
}