跳转到内容

国家

基于 ISO 3166 的国家定义。

CountryAlpha2

基类: str

CountryAlpha2 解析 ISO 3166-1 alpha-2 格式的国家代码。

from pydantic import BaseModel

from pydantic_extra_types.country import CountryAlpha2

class Product(BaseModel):
    made_in: CountryAlpha2

product = Product(made_in='ES')
print(product)
#> made_in='ES'

alpha3 属性

alpha3: str

国家代码以 ISO 3166-1 alpha-3 格式表示。

numeric_code 属性

numeric_code: str

国家代码以 ISO 3166-1 数字 格式表示。

short_name 属性

short_name: str

国家简称。

CountryAlpha3

基类: str

CountryAlpha3 解析 ISO 3166-1 alpha-3 格式的国家代码。

from pydantic import BaseModel

from pydantic_extra_types.country import CountryAlpha3

class Product(BaseModel):
    made_in: CountryAlpha3

product = Product(made_in="USA")
print(product)
#> made_in='USA'

alpha2 属性

alpha2: str

国家代码以 ISO 3166-1 alpha-2 格式表示。

numeric_code 属性

numeric_code: str

国家代码以 ISO 3166-1 数字 格式表示。

short_name 属性

short_name: str

国家简称。

CountryNumericCode

基类: str

CountryNumericCode 解析 ISO 3166-1 数字 格式的国家代码。

from pydantic import BaseModel

from pydantic_extra_types.country import CountryNumericCode

class Product(BaseModel):
    made_in: CountryNumericCode

product = Product(made_in="840")
print(product)
#> made_in='840'

alpha2 属性

alpha2: str

国家代码以 ISO 3166-1 alpha-2 格式表示。

alpha3 属性

alpha3: str

国家代码以 ISO 3166-1 alpha-3 格式表示。

short_name 属性

short_name: str

国家简称。

CountryShortName

基类: str

CountryShortName 解析短名称格式的国家代码。

from pydantic import BaseModel

from pydantic_extra_types.country import CountryShortName

class Product(BaseModel):
    made_in: CountryShortName

product = Product(made_in="United States")
print(product)
#> made_in='United States'

alpha2 属性

alpha2: str

国家代码以 ISO 3166-1 alpha-2 格式表示。

alpha3 属性

alpha3: str

国家代码以 ISO 3166-1 alpha-3 格式表示。

numeric_code 属性

numeric_code: str

国家代码以 ISO 3166-1 数字 格式表示。