小编Spa*_*xxy的帖子

如何在没有字符串连接的情况下在Python中重复字符?

我目前正在编写一个进行频率分析的短程序.然而,有一条线困扰着我:

"{0[0]}  | " + "[]" * num_occurrences + " Total: {0[1]!s}"
Run Code Online (Sandbox Code Playgroud)

在Python中有没有一种方法可以重复某些字符而不需要连接(最好是在格式字符串中)?我不觉得我是以最恐怖的方式做这件事.

python string concatenation format-string

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

concatenation ×1

format-string ×1

python ×1

string ×1