Python タプルの文字列を結合するサンプル

環境
Windows 11 Pro 64bit
Python 3.11

構文
変数名 = ".join(タプル名)
join()を使って、引数に指定したタプルの文字列を結合した文字列を返します。
join()の引数にタプルを指定します。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ns = ('s', 't', 'u', 'd', 'y')
res = ''.join(ns)
print(res)
ns = ('s', 't', 'u', 'd', 'y') res = ''.join(ns) print(res)
ns = ('s', 't', 'u', 'd', 'y')

res = ''.join(ns)

print(res)

実行結果
study

Python

Posted by arkgame