在Python中,你可以使用 `math.pow` 函数来计算一个数的立方根。以下是使用 `math.pow` 函数计算立方根的示例代码:
import mathdef cube_root(x):return math.pow(x, 1/3)测试函数print(cube_root(8)) 输出应为2.0
如果你需要计算其他数的立方根,只需将 `x` 替换为相应的数值即可。

另外,你还可以使用 `numpy` 库中的 `np.cbrt` 函数来计算立方根,例如:
import numpy as npresult = np.cbrt(-64) 结果应为 -4.0print(result)
