我有一长串的选择题,像这样:
8. OVERT (R.R.B. 1996)
(a) Deep (b) Shallow
(c) Secret (d) Unwritten
9. ACCORD (Railways, 1991)
(a) Solution (b) Act
(c) Dissent (d) Concord
我想把这个选项[(a)(b)(c)(d)]放在问题旁边,有这样一个标签:
8. OVERT (R.R.B. 1996) (a) Deep (b) Shallow (c) Secret (d) Unwritten
9. ACCORD (Railways, 1991) (a) Solution (b) Act (c) Dissent (d) Concord
我在(a)
之前使用了"\b"
,如下所示:
newString = QuestionString.replace("(a)", "\b(a)")
但是这只删除了(a)
前面的一些空格。但是我想删除它前面的换行符。有人能建议我如何使用python删除它吗
试一试
您可以使用正则表达式:
并将其替换为
见a demo on regex101.com
您可以尝试使用以下模式替换正则表达式:
这将针对所有而非的CR?LF,然后是一个数字点线,该点线开始下一节。将替换字符串设为空,以删除此类匹配的CR?LF
这张照片是:
相关问题 更多 >
编程相关推荐