gpt4 book ai didi

Python 无法拆分零宽度 anchor ?

转载 作者:太空狗 更新时间:2023-10-29 21:36:43 28 4
gpt4 key购买 nike

<分区>

import re

s = 'PythonCookbookListOfContents'

# the first line does not work
print re.split('(?<=[a-z])(?=[A-Z])', s )

# second line works well
print re.sub('(?<=[a-z])(?=[A-Z])', ' ', s)

# it should be ['Python', 'Cookbook', 'List', 'Of', 'Contents']

如何使用 Python re 从小写字符和大写字符的边界拆分字符串?

为什么第一行不行,第二行可以用?

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com