Is str.replace(..).replace(..) ad nauseam a standard idiom in Python?

前端 未结 9 1402
迷失自我
迷失自我 2020-12-20 11:19

For instance, say I wanted a function to escape a string for use in HTML (as in Django\'s escape filter):

    def escape(string):
        \"\"\"
        Retu         


        
9条回答
  •  庸人自扰
    2020-12-20 11:39

    Apparently it's pretty common to implement that via regex. You can find an example of this at ASPN and here.

提交回复
热议问题