日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網營銷解決方案
創(chuàng)新互聯(lián)Python教程:tomllib—-ParseTOMLfiles

tomllib —- Parse TOML files

3.11 新版功能.

Source code: Lib/tomllib


This module provides an interface for parsing TOML (Tom’s Obvious Minimal Language, https://toml.io). This module does not support writing TOML.

參見

The Tomli-W package is a TOML writer that can be used in conjunction with this module, providing a write API familiar to users of the standard library marshal and pickle modules.

參見

The TOML Kit package is a style-preserving TOML library with both read and write capability. It is a recommended replacement for this module for editing already existing TOML files.

This module defines the following functions:

tomllib.load(fp, /, **, parse_float=float*)

Read a TOML file. The first argument should be a readable and binary file object. Return a dict. Convert TOML types to python using this conversion table.

parse_float will be called with the string of every TOML float to be decoded. By default, this is equivalent to float(num_str). This can be used to use another datatype or parser for TOML floats (e.g. decimal.Decimal). The callable must not return a dict or a list, else a ValueError is raised.

A TOMLDecodeError will be raised on an invalid TOML document.

tomllib.loads(s, /, **, parse_float=float*)

Load TOML from a str object. Return a dict. Convert TOML types to Python using this conversion table. The parse_float argument has the same meaning as in load().

A TOMLDecodeError will be raised on an invalid TOML document.

The following exceptions are available:

exception tomllib.TOMLDecodeError

Subclass of ValueError.

Examples

Parsing a TOML file:

 
 
 
 
  1. import tomllib
  2. with open("pyproject.toml", "rb") as f:
  3. data = tomllib.load(f)

Parsing a TOML string:

 
 
 
 
  1. import tomllib
  2. toml_str = """
  3. python-version = "3.11.0"
  4. python-implementation = "CPython"
  5. """
  6. data = tomllib.loads(toml_str)

Conversion Table

TOML

Python

table

dict

string

str

integer

int

float

float (configurable with parse_float)

boolean

bool

offset date-time

datetime.datetime (tzinfo attribute set to an instance of datetime.timezone)

local date-time

datetime.datetime (tzinfo attribute set to None)

local date

datetime.date

local time

datetime.time

array

list


文章名稱:創(chuàng)新互聯(lián)Python教程:tomllib—-ParseTOMLfiles
分享網址:http://m.5511xx.com/article/cojogeo.html