반응형
나는 a를 취하는 pad_with_n_chars (s, n, c)
함수를 정의해야한다.
string 's', an integer 'n', and a character 'c' and returns
a string consisting of 's' padded with 'c' to create a
string with a centered 's' of length 'n'. For example,
pad_with_n_chars(”dog”, 5, ”x”)
should return the
문자열 " xdogx
".
해결 방법
In [18]: '{s:{c}^{n}}'.format(s='dog',n=5,c='x')
Out[18]: 'xdogx'
참조 페이지 https://stackoverflow.com/questions/4008546
반응형
'파이썬' 카테고리의 다른 글
파이썬에서 별표 *는 무엇을 의미합니까? (0) | 2020.10.27 |
---|---|
파이썬 쉼표를 도트 팬더로 대체 (0) | 2020.10.27 |
파이썬 Python의 RotatingFileHandler 사용 방법 (0) | 2020.10.27 |
파이썬 언제 적용 (pd.to_numeric)하고 언제 파이썬에서 astype (np.float64)을해야합니까? (0) | 2020.10.27 |
파이썬 Django Forms에서 CSS 클래스 정의 (0) | 2020.10.27 |
댓글