Pythonで同じ文字列を繰り返す、リピートする方法

IT

Pythonでは文字列を掛け算した場合、その文字列を掛け算の数だけ繰り返すことができます。

スポンサーリンク

文字列をリピート

python string repeat1
実演するとこうなります。用意しておいた文字列に対し、
#python
文字列 = "abc"
文字列 = 文字列 * 3
print(文字列)
掛け算を実行して代入します。
python string repeat2
同じ文字列が繰り返されることが確認できます。
Python操作方法、関数・メソッドリファレンス
使用用途別にまとめたPythonリファレンスページです。 初期準備、基本概念 ダウンロード、インストール、起動 ShellとEditor、保存、実行 保存したPythonの起動 コメント、docstring、行またぎ コメント、...

コメント

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny