Python,join()メソッドの使用
1244 ワード
説明:
構文:
パラメータ:
戻り値:
例:
出力結果:
例2
出力結果:
Python join()
構文:
str.join(sequence)
パラメータ:
sequence 、 、 、
戻り値:
例:
str = "-";
seq = ("a", "b", "c") #
print str.join(seq)
出力結果:
a-b-c
例2
#1)
LIST =["I","am","bigship","come","from","China"]
print (' '.join(LIST))
#2)
str="i am bigship"
print('->'.join(str))
#3)
TUPLE = ("I","am","bigship","come","from","China")
print(' '.join(TUPLE))
#4)
Dir ={'b':1,'i':2,'g':3,'s':4,'h':5,'p':7}
print( ':'.join(Dir))
出力結果:
I am bigship come from China
i-> ->a->m-> ->b->i->g->s->h->i->p
I am bigship come from China
b:i:g:s:h:p
list = ['a','b','c','d']
print('+'.join(list))
:
a+b+c+d