Python string formatting: % vs concatenation

前端 未结 4 986
不思量自难忘°
不思量自难忘° 2020-12-09 12:05

I\'m developing an application in which I perform some requests to get an object id. After each one of them, I call a method (get_actor_info()) passing this id

4条回答
  •  萌比男神i
    2020-12-09 12:48

    Concatenation is better when it comes to performance. In your example, both concatenation and substitution are readable but when it comes to more complex templates, substitution wins the simplicity and readability race.

    For example, if you have data and you want show it in html, concatenation will cause you headache, while substitution will be simple and readable.

提交回复
热议问题