我有下面的字符串。我只需要删除单引号之间部分的空格。剩下的部分应该是完整的
+amk=0 nog = 0 nf=1 par=1 mg =0.34e-6 sd='((nf != 1) ? (nf-1)) :0)' sca=0 scb=0 scc=0 pj='2* ((w+7.61e-6) + (l+8.32e-6 ))'
所以输出应该是
+amk=0 nog = 0 nf=1 par=1 mg =0.34e-6 sd='((nf!=1)?(nf-1)):0)' sca=0 scb=0 scc=0 pj='2*((w+7.61e-6)+(l+8.32e-6))'
是否可以用一个Regex语句来实现这一点?或者需要多条线路?你知道吗
作为一种选择,您可能需要考虑有限状态机。我总是忘了图书馆,但它是超级简单的创建自己。像这样:
另见:Is list join really faster than string concatenation in python?
相关问题 更多 >
编程相关推荐