move python demos to _pydemo
This commit is contained in:
16
_pydemo/callpy/call.go
Normal file
16
_pydemo/callpy/call.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/goplus/llgo/c"
|
||||
"github.com/goplus/llgo/py"
|
||||
)
|
||||
|
||||
func main() {
|
||||
py.Initialize()
|
||||
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)
|
||||
py.Finalize()
|
||||
}
|
||||
Reference in New Issue
Block a user