6.3. GSettings 值

每个 GSettings 键都将特定设置的值存储为 GVariant 数据类型。要修改键的值,您必须使用 GVariant 文本格式指定值。

GVariant 支持以下数据类型:

数据类型GVariant 文本格式示例

Boolean

  • true
  • false

String

  • 'option1'
  • "option2"

Number

  • 5
  • 37.5
  • 3.75e1

tuple

  • ("hello", 42)

Array

  • [1, 2, 3]

Dictionary

  • {1: "one", 2: "two", 3: "three"}

Variant

  • [<"hello">, <42>]

Maybe

  • just 'hello'
  • nothing

Byte string

  • b'abc'
  • b"abc"