Help us understand the problem. What is going on with this article?

Pythonの文法 - 文字列操作

More than 3 years have passed since last update.
  • 初めてのPython。わからないことをわかったベースで追記していきます。


# 間を「+」で連結
message = 'Hello' + ' ' + 'world'

# スペース空けて並べるでも良いらしい。(可読性ぇ…。)
message = 'Hello' ' ' 'world'


  • そのまま「+」で文字列と結合するとTypeErrorが発生。数値はstr()で変換する。
#print('test' + 123) # TypeError: Can't convert 'int' object to str implicitly

print('test' + str(123))
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away