gpt4 book ai didi

python - 从 python 中的字符串中删除 LaTeX 字符

转载 作者:太空宇宙 更新时间:2023-11-03 15:45:34 24 4
gpt4 key购买 nike

<分区>

我有一个像这样的 TeX 文档

s = '\textbf{1 + 1} \begin{center} \textbf{some text in here:} \end{center} and \textbf{2} etc'

我想删除 \textbf{ 和右大括号 }

所以最终的文本看起来像这样

1 + 1 \begin{center} some text in here: \end{center} and 2 etc' 

这是我目前的尝试

import re 

re.sub(r'\textbf{(.*)}', '\\1', s)

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