iT邦幫忙

2018 iT 邦幫忙鐵人賽
DAY 6
1
Data Technology

Python學習筆記系列 第 6

[ Day6 ] Strings 字串介紹

字串用來記錄文字資訊,像是名字。在python裡,字串是一個序列,意思是說python持續在字串裡追蹤自傳裡每個元素。

舉例來說,python以特殊排序方式讀取hello這個字串裡的字母


1. 首先,我們先來創造字串並印出字串

https://ithelp.ithome.com.tw/upload/images/20171209/20107290bV4Tw7wD0u.png

https://ithelp.ithome.com.tw/upload/images/20171209/20107290iWmrNojugZ.png

https://ithelp.ithome.com.tw/upload/images/20171209/20107290sOPMz1IG9D.png


2. 字串索引

https://ithelp.ithome.com.tw/upload/images/20171209/20107290ypjxejfbGU.png

https://ithelp.ithome.com.tw/upload/images/20171209/201072907PbdkJzwNw.png


** 3. 字串特性**

值得注意的是,字串有個重要特性是”不變性”,意思是說當你創造一個字串後,在裡面的元素不可以被改變獲取帶,如以下例子

https://ithelp.ithome.com.tw/upload/images/20171209/20107290k8f9328D0z.png


4. 內建字串函數

Python裡的物件通常有內建字串函數,這個方法是將物件放在函數當中讓物件可以執行指令
請詳以下範例

https://ithelp.ithome.com.tw/upload/images/20171209/20107290Q6c1nUakiH.png

參考資料來源: Go from zero to hero in Python


上一篇
[Day5] Numbers簡易數值運算
下一篇
[ Day7 ] 格式化輸出
系列文
Python學習筆記14
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言