python函数积累

Posted BobHuang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python函数积累相关的知识,希望对你有一定的参考价值。

给定前后字符串获取中间字符串

def GetMiddleStr(content,startStr,endStr):
    startIndex = content.index(startStr)
    if startIndex>=0:
        startIndex += len(startStr)
    endIndex = content.index(endStr)
    return content[startIndex:endIndex]

cookie字符串转换为字典

def stringToDict(cookie):
    itemDict = {}
    items = cookie.split(‘;‘)
    for item in items:
        key = item.split(‘=‘)[0].replace(‘ ‘, ‘‘)
        value = item.split(‘=‘)[1]
        itemDict[key] = value
    return itemDict

以上是关于python函数积累的主要内容,如果未能解决你的问题,请参考以下文章

Python-Numpy库的扩维(维度扩展)操作示例代码积累

python函数积累

python内置函数积累

python常见函数积累

QT 实用代码片段

13 个非常有用的 Python 代码片段