GLib.VariantType

測試環境

  • Xubuntu 16.04 64位元

執行

$ lsb_release -a

顯示

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04 LTS
Release:    16.04
Codename:   xenial

執行

$ python3 -V

顯示

Python 3.5.1+

執行

$ dpkg -l python3-gi

顯示

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                     Version           Architecture      Description
+++-========================-=================-=================-======================================================
ii  python3-gi               3.20.0-0ubuntu1   amd64             Python 3 bindings for gobject-introspection libraries

進入 Python Console

執行

$ python3

顯示

Python 3.5.1+ (default, Mar 30 2016, 22:46:26)
[GCC 5.3.1 20160330] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

載入相關模組

載入「GLib」

>>> from gi.repository import GLib

觀看 help

輸入

>>> help(GLib.VariantType)

輸入「q」,回到「Python console」。(操作上應該跟less類似)

輸入

>>> print(GLib.VariantType.__doc__)

顯示

:Constructors:

::

    new(type_string:str) -> GLib.VariantType
    new_array(element:GLib.VariantType) -> GLib.VariantType
    new_dict_entry(key:GLib.VariantType, value:GLib.VariantType) -> GLib.VariantType
    new_maybe(element:GLib.VariantType) -> GLib.VariantType
    new_tuple(items:list) -> GLib.VariantType

使用範例

顯示

>>> GLib.VariantType('()')

顯示

<GLib.VariantType object at 0x7fe416188288 (GVariantType at 0x2929fb0)>

輸入

>>> GLib.VariantType('(s)')

顯示

<GLib.VariantType object at 0x7fe416188288 (GVariantType at 0x293d380)>

輸入

>>> GLib.VariantType('(ss)')

顯示

<GLib.VariantType object at 0x7fe415e55528 (GVariantType at 0x297b390)>

參考文件

Api