Python中开方有好多方法 ** math
import math
print(8 ** 1/3) # 2.6666666666666665
print(8 ** 1.0/3) # 2.6666666666666665
print(8.0 ** 1/3) # 2.6666666666666665
print(math.pow(8, 1/3)) # 2.0
print(math.pow(8, 1.0/3)) # 2.0
# 负数的开方要先加上绝对值
print(math.pow(abs(-8), 1/3) * (-1) if -8 < 0 else 1) # -2.0