pythonでリストの要素をカンマ区切りで出力したい場合がある。
例えば普通にprint
すると以下のように出力されるところを、
['player', 7, 2, 1]
以下のように出力したい場合
player,7,2,1
print(*l, sep=',')
のようにすればOK
print(l) # ['player', 7, 2, 1]
print(*l, sep=',') # player,7,2,1
以上です
Go to list of users who liked
More than 3 years have passed since last update.
pythonでリストの要素をカンマ区切りで出力したい場合がある。
例えば普通にprint
すると以下のように出力されるところを、
['player', 7, 2, 1]
以下のように出力したい場合
player,7,2,1
print(*l, sep=',')
のようにすればOK
print(l) # ['player', 7, 2, 1]
print(*l, sep=',') # player,7,2,1
以上です
Register as a new user and use Qiita more conveniently
Go to list of users who liked