字串:str1 = '123'
str2 ="123"
str3 = """123"""
str4 = '''123''' 三引號可以換行
字串不可變序列
獲取字元---- 切片方式
str1 = "12345678"
str1[2:3] # 3
str1[5] # 6
原生字元表示:r"1234\56" 表示的就是不需要轉義,
字串拼接:str1 + str2 , "1234" + "7890" # "12347890"
兩個字串直接挨著寫,"1234""56789" # "123456789" 其實相當於自動拼接了
字串重複 str1 * 3 生成乙個新的字串相當於多個字串拼接,
成員操作 in , not in
測量字串長度:len(str1) #返回str1的長度
Python基礎程式設計 十七 檔案
本篇文章主要是對python學習時的一些總結,作為學習筆記記錄。python中對於檔案也提供了操作的介面。對於檔案來說,如需對檔案進行讀寫操作,首先就需要開啟檔案。open 函式的函式簽名為 open file,mode r buffering 1,encoding none,errors none...
python基礎函式式程式設計(十七)
概念 包括lambda函式的程式設計 高階函式變成 print sum 1,2,3 def test x,f return f x x 1,2,3 print test x,sum lamda匿名函式 def test x,y return x 2 y 這個lamda實現的函式和上面的函式是等價的 ...
Python程式設計基礎之Python基礎
1.只能是乙個詞 2.包含字母,數字和下劃線 3.不能以數字開頭 this program syas hello and asks for your name print hello world1 print what is your name?ask for their name myname i...