“笨辦法”學python3》Ex 10
阿新 • • 發佈:2018-12-20
知識點:
輸出轉義字元
轉義字元 | 功能 |
\\ | \ |
\' | ' |
\" | " |
\a | 響鈴符 |
\b | 退格符 |
\f | 進紙符 |
\n | 換行符 |
\N{name} | Unicode 資料庫中字元名,name是名字 |
\r | 回車 |
\t | 製表符 |
\uxxxxx | 值為16進位制的xxxx字元 |
程式:
tabby_cat = "\tI'm tabbed in." persian_cat = "I'm split\non a line." backslash_cat = "I'm t\at\bt\ft a \\ cat." fat_cat = """ I'll do a list. \t* Cat food \t* Fishies \t* Catnip\n\t* Grass """ print(tabby_cat) print(persian_cat) print(backslash_cat) print(fat_cat)
輸出:
PS C:\Users\xue weiruan\github> python ex10.py
I'm tabbed in.
I'm split
on a line.
I'm tt a \ cat.
I'll do a list.
* Cat food
* Fishies
* Catnip
* Grass
PS C:\Users\xue weiruan\github>