python根据指定字符串截取特定字符

if __name__ == '__main__':

    a='单据ddd明细中商品01010130088ddd0001未1111dd上传DDD'
    print(len(a))

    start_index=a.find("品") + 1
    start_index1 = a.find("未")
    end_index=len(a) - start_index
    middle_data = a[start_index: start_index1]
    print(start_index)
    print(end_index)
    print(middle_data)
输出
40
10
30
01010130088ddd0001
posted @ 2024-08-01 22:31  darling331  阅读(9)  评论(0编辑  收藏  举报