Pythonで文字列をつなげる、連結する方法

typography IT

Pythonで文字列を連結する場合、文字列同士を+でつなげばOKです。

スポンサーリンク

文字列の連結

#python
文字列 = "a" + "b" + "c"
print(文字列)
文字列同士を+でつなげば、
python stringplus1
ひとつの文字列に連結することができます。
python stringplus2
string型の変数であれば、変数と文字列を繋ぐこともできます。

文字列にint型の数字をつなぐなどはエラーになるので、その場合一度型変換をする必要があります。

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