Example:
Content (1) host_header.yaml file
Host: https://testapp.goodiber.com/v2/ # DEV1 test environment domain # request parameter common interface in the request header headers: " Version " : " 2.3.0 " " Version-ID " : " 235 " " os " : " ios " " Sign " : " 123456 " " IS-the Test " : " 1 "
(2) todo_report.py file to read the contents of host_header.yaml
Import yaml, SYS # Host yaml introduced in reload (SYS) sys.setdefaultencoding ( " UTF-. 8 " ) with Open (The os.getcwd () [: -5] + " /Config/host_header.yaml " , ' RB ' ) AS F: Data = yaml.load (F) Host = Data [ " Host " ] # acquired URL header = Data [ " headers " ] # acquired parameter value in the entire headers
OS = Data [ "headers"] [ "os"] # to get the value of headers in OS