---
# System prepended metadata

title: 7.字串型態與len函數說明與實作
tags: [' 筆記', python基礎語法與應用]

---

---
title: 7.字串型態與len函數說明與實作
tags: python基礎語法與應用, 筆記
---

## 7.字串型態與len函數說明與實作
```
a= "Hello"
print(a)
→ Hello

```
:::info
a = a+ "Python"
print(a)

:::spoiler 答案
HelloPython

:::

同類型才能運算
a = a + "3"print(a)
→HelloPython3

print("長度：", len(a))
→ 長度：12

print(a[5])
→p

print(a[len(a)-1])
→3
＃冒號後面不包含結尾
print(a[4:8])
→oPyt

print(a[1:])
→elloPython3


- 文字 從零開始
“HelloPython”
 012345678910
 記得減1
 
 # END
 
 ![](https://i.imgur.com/I0Sz1HH.png)
