安装的是Python3.11版本,然后安装PyCharm2024版本,在编写字符串高级分割的时候语句如下:
import re
a = 'i,you fromplace\nidea'
print(re.split(',| ||',a))
运行时出现错误,如下:
C:\Users\是韩愈鸭\PycharmProjects\pythonProject1.venv\Scripts\python.exe C:\Users\是韩愈鸭\PycharmProjects\pythonProject1\ppp.py
Traceback (most recent call last):
File "C:\Users\是韩愈鸭\PycharmProjects\pythonProject1\ppp.py", line 3, in <module>
print(re.split(',| |*|',a))
^^^^^^^^^^^^^^^^^^^^
File "D:\python\Lib\re__init.py", line 206, in split
return _compile(pattern, flags).split(string, maxsplit)
^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\python\Lib\re__init.py", line 294, in _compile
p = _compiler.compile(pattern, flags)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\python\Lib\re_compiler.py", line 745, in compile
p = _parser.parse(p, flags)
^^^^^^^^^^^^^^^^^^^^^^^
File "D:\python\Lib\re_parser.py", line 989, in parse
p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\python\Lib\re_parser.py", line 464, in parse_sub
itemsappend(parse(source, state, verbose, nested + 1,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\python\Lib\re_parser.py", line 691, in _parse
raise source.error("nothing to repeat",
re.error: nothing to repeat at position 4
搞不懂是咋回事了,求助求助啊