ตัวแปรร่วม

ตัวแปรส่วนกลางต่อไปนี้สามารถใช้ได้ทั่วโลก

  • อินเทอร์เฟซ Python ทั่วโลก

    คุณสามารถนำเข้าโมดูล Python และเข้าถึงประเภทและฟังก์ชันในตัวของ Python ผ่านตัวแปรโกลบอล Python

    import Python
    // Import modules.
    let os = Python.import("os")
    let np = Python.import("numpy")
    
    // Use builtin types and functions.
    let list: PythonObject = [1, 2, 3]
    print(Python.len(list)) // Prints 3.
    print(Python.type(list) == Python.list) // Prints true.
    

    คำประกาศ

    public let Python: PythonInterface