使用fill char和counter创建python字符串

Car*_*cio 4 python string

我想以优雅的方式做到这一点:

>>> ''.zfill(5, '-')
'-----'
Run Code Online (Sandbox Code Playgroud)

有没有办法用fill char和counter初始化一个字符串?当然,数量可能会有所不同.

ber*_*rni 12

试一试:

>>> '-'*5
'-----'
Run Code Online (Sandbox Code Playgroud)

在Python中就这么简单:)