What is Schema in python.

Insha.
Apr 30, 2021

--

Schema is a python library which is used to validate python structure .
Basically to check whether we are providing/assigning correct data type or not.

for using schema we have to install the schema library.

!pip install schema pip install schema

now create schema

from schema import Schemaschema=Schema([‘name’:(str)])data1=([{‘name’:”msatutorpy@gmail.com”}])print(schema.is_valid(data1))#output — Truedata2=([{‘name’:67}])print(schema.is_valid(data2))#output — False

#The output show which value we can accept as str / string value .
data1 variable is in correct schema format, whereas data2 is in not schema function as we are providing integer in place of string.

--

--

Insha.
Insha.

No responses yet