MCPcopy Create free account
hub / github.com/boy-hack/hack-requests / extract_dict

Function extract_dict

HackRequests/HackRequests.py:27–39  ·  view source on GitHub ↗

根据分割方式将字符串分割为字典 Args: text: 分割的文本 sep: 分割的第一个字符 一般为'\n' sep2: 分割的第二个字符,默认为'=' Return: 返回一个dict类型,key为sep2的第0个位置,value为sep2的第一个位置 只能将文本转换为字典,若text为其他类型则会出错

(text, sep, sep2="=")

Source from the content-addressed store, hash-verified

25
26
27def extract_dict(text, sep, sep2="="):
28 """根据分割方式将字符串分割为字典
29 Args:
30 text: 分割的文本
31 sep: 分割的第一个字符 一般为'\n'
32 sep2: 分割的第二个字符,默认为'='
33 Return:
34 返回一个dict类型,key为sep2的第0个位置,value为sep2的第一个位置
35
36 只能将文本转换为字典,若text为其他类型则会出错
37 """
38 _dict = dict([l.split(sep2, 1) for l in text.split(sep)])
39 return _dict
40
41
42class httpcon(object):

Callers 2

httpMethod · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected