![](/img/trans.png)
[英]How do i remove the square brackets [ ] that are printed with the number in my string
[英]python REGEX - How Do I remove Square brackets from string?
A = """ 這是我的 [name duty 受到解決時間的情況],最后我叫了 "man \fjd" 所以你照顧那個東西。"""
這是一個隨機字符串,可能類似於我的問題。
我想像這樣 output
[名稱職責受到解決 - 時間情況###沒有方括號但在 python 中使用finditer我也需要解決方案
括號內的 man \fjd ### 材料使用 re.finditer ....
a= """This is my [name Duty subjected to solve - time situation ] and finally I called "the man \fjd " so you take of care of that thing."""
pattern =''' I nEDD THIS ANSwers '''
for item in finditer(pattern ,a, re,VERBOSE :
return(item.groupdict())
為什么只需要正則表達式來刪除方括號? 您可以簡單地使用替換來完成工作!
a = a.replace('[', '').replace(']', ''])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.