Python equivalent of Java StringBuffer?

后端 未结 8 1291
半阙折子戏
半阙折子戏 2020-12-04 21:10

Is there anything in Python like Java\'s StringBuffer? Since strings are immutable in Python too, editing them in loops would be inefficient.

8条回答
  •  攒了一身酷
    2020-12-04 21:36

    In the top answer, the link from "Efficient String Concatenation in Python" no longer links to the intended page (redirects to tensorflow.org instead). However, this page from 2004 with the exact code cited probably represents that page https://waymoot.org/home/python_string/ .

    You may have seen it already since it comes up first if you google:

             efficient python StringBuilder
    

    I can't leave this in a comment, as I'm not privileged.

提交回复
热议问题