Skip to main content

ログ取得ツール (移転先予定地)

衝撃+衝撃=?

Pythonの文字列の連結は「+」だった!!

…驚いている自分が辛い。今まで、"".join([“a”,“b”])を使っていたのはヒミツにしといたほうが信用を失わずに済むかもしれない。


>>> "a"+"b"
'ab'
>>> 1+"b"
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: unsupported operand types for +: 'int' and 'str'
>>> str(1)+"b"
'1b'
>>> repr(1)+"b"
'1b'
>>> `1`+"b"
'1b'
>>> `1+10`+"b"
'11b'
>>> 

(追記) 2003-09-17 10:31

掛け算もできるんだ…ふーん。