標籤:ima 它的 總結 html print blog ref 不能 技術分享
這是12月規劃的內容,2018年一月開篇~
如果有什麼錯誤,還請提出來~
Python print函數 一
Python 中的變數賦值不需要型別宣告,好了知道這個就可以了
我們還可以看一看類型
1 num=1.2332 str="1.233"3 print(type(num))4 print(type(str))
<class ‘float‘><class ‘str‘>
資料類型-字串
單引號,雙引號用法相同
1 str="1.233"2 string=‘1.233‘3 print(str)4 print(string)
1.2331.233
三引號表示多行的字串
1 str=‘‘‘asdasd2 asdasdasd3 asdasdasd4 adas‘‘‘5 print(str)
asdasdasdasdasdasdasdasdadas
還有各種的轉義...我覺得記一點常用的就行了,其他用的時候再查一查
| 逸出字元 |
描述 |
| \(在行尾時) |
續行符 |
| \\ |
反斜線符號 |
| \‘ |
單引號 |
| \" |
雙引號 |
還有它的運算子
+,*都表示過了,我們看一看[ ],in,not in
1 str="helloworld"2 print(str[1])3 print(str[1:4])#區間是左閉右開,注意負數是從右至左4 print(str[:5])5 print(str[4:])
eellhellooworld
1 str="helloworld"2 print("h"in str)3 print("h" not in str)
TrueFalse
r或者R,原始字串 - 原始字串:所有的字串都是直接按照字面的意思來使用,沒有轉義特殊或不能列印的字元。轉義記不住的可以用這個
1 str=r"D:\eclipse\readme"2 print(str)
D:\eclipse\readme
最後它的內建函式,自己一個個玩吧~以後會有個總結。
Python 變數 資料類型-字串 二