pyimport & deomo: callpy (todo)

This commit is contained in:
xushiwei
2024-05-11 06:23:05 +08:00
parent 29830865d9
commit cca46573ea
7 changed files with 87 additions and 11 deletions

View File

@@ -10,7 +10,10 @@ func main() {
py.SetProgramName(*c.Argv)
math := py.ImportModule(c.Str("math"))
sqrt := math.GetAttrString(c.Str("sqrt"))
sqrt2 := sqrt.CallOneArg(py.Float(2)).FloatAsDouble()
c.Printf(c.Str("sqrt(2) = %f\n"), sqrt2)
sqrt2 := sqrt.CallOneArg(py.Float(2))
c.Printf(c.Str("sqrt(2) = %f\n"), sqrt2.FloatAsDouble())
sqrt2.DecRef()
sqrt.DecRef()
math.DecRef()
py.Finalize()
}