How to repeat whitespace

前端 未结 2 1098
感动是毒
感动是毒 2020-12-22 10:09

I am trying to get a string like the following one:

[==== ]

For that purpose I am using this code:



        
2条回答
  •  一向
    一向 (楼主)
    2020-12-22 10:57

    Browsers collapse multiple whitespace, in order to force it not to you can use non-breaking spaces.

    Therefore, in your case you can use

    ' '.repeat(4)
    

    (Its arguable that a debug console shouldn't collapse the whitespace, but in your case it seems it does)

提交回复
热议问题