[文字處理篇] 字串操作 - tsungjung411/python-study GitHub Wiki
prefix 前綴
>>> s='a\nb\nc'
>>> s
'a\nb\nc'
>>> print(s)
a
b
c
>>> s=r'a\nb\nc'
>>> s
'a\\nb\\nc'
>>> print(s)
a\nb\nc
- 參考資料
- What does preceding a string literal with "r" mean? [duplicate]
The r means that the string is to be treated as a raw string, which means all escape codes will be ignored.
- What does preceding a string literal with "r" mean? [duplicate]
參考資料
- How to Substring a String in Python
- 字串型態
- 雙引號
- 單引號
- 跳離(Escape)
- 原始字串(Raw String)
- 三重引號
- for迴圈
- in運算子
- +運算子
- ord(), chr(), encode(), decode()
- 切片(Slice)
- index(), upper(), lower(), startswith()