iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 5
1
AI & Data

大數據與AI研習實作與心得 系列 第 5

Python - String字串

字串操作有*乘法
程式

 BadMan = '王小明'
 hate="我恨你"
 wantToTellYou = BadMan + 3*hateWord

https://ithelp.ithome.com.tw/upload/images/20200920/20112100cF2G2F6tpL.png
執行結果:

王小明我恨你我恨你我恨你


字串截取操作
程式

word='Python'
print (word[0])
#代表index第0個字元
word='Python'
print(word[0:3])
#代表index第0~第3不包含第3個字串

執行結果:

P
Pyt


上一篇
Python - 總覽&第一支程式&基本知識
下一篇
Python - 數值運算&運算式運算
系列文
大數據與AI研習實作與心得 30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言