【hisword 2017】Python Notebook-str文字列
3829 ワード
文字列の使用方法:1,文字列の定義2,文字列の見竜卸甲strip 3,文字列の除去間隔split 4,文字列のつなぎ合わせマスターjoin
コード:
コード:
#
rstr = ''
rstr = "Isaac's toy"
print('rstr = %s' %rstr)
:rstr= Isaac's toy
# strip
rstr = ' !
'
print('rstr = %s' %rstr)
rstr = rstr.strip('
')
print('rstr = %s' %rstr)
rstr = rstr.strip('!')
print('rstr = %s' %rstr)
:
rstr = !
rstr = !
rstr =
# split
rstr = ' '
rlist_tnsstarname = rstr.split(' ')
print(rlist_tnsstarname)
for name in rlist_tnsstarname:
print(name)
:
['\x08 ', ' ', ' ']
# join
rstr = ','
rstr = rstr.join(rlist_tnsstarname)
print('rstr = %s' %rstr)
:
rstr = , ,