1、去python官網(wǎng)下載安裝python即可在終端窗口運行程序
2、下載文本編輯器 Sublime text3
3、基礎(chǔ)知識學(xué)習(xí)
? ? 3.1變量?
? ??????????message="Hello world! "
????????????print(message)
????????????massage="I decide to study computer!"
????????????print(massage)
? ? ? python始終記錄變量的最新值。
? ? 3.2 變量名以字母或下劃線開頭,只能包含數(shù)字、字母或下劃線。
? ? 3.3 修改字符串大小寫
????????name="ada lovelace"
????????print(name.title())? ?//以首字母大寫的方式顯示每個單詞
????????print(name.upper())? ? ?//全部大寫顯示
????????print(name.lower())? ? //全部小寫顯示
????3.4 拼接字符串
????????first_name="xu"
????????last_name="grey"
????????full_name=first_name+" "+last_name
????????print(full_name)
????????print("Hello, "+full_name.title() +"!")? ? //拼接創(chuàng)建信息
? ? 3.5 添加空白
? ??????print("\n\tlaboratory")? ? //換行符或制表符添加空白
? ? 3.6 刪除空白
????????favorite_language=' python '
????????favorite_language.lstrip()? ? //刪除開頭空白
????????favorite_language.rstrip()? ? //刪除末尾空白
????????favorite_language.strip()? ? //刪除兩端空白
? ? 3.7 str()函數(shù)
????????age=23
????????message="Happy "+str(age)+"rd Birthday!"? ? //str()轉(zhuǎn)為字符
????????print(message)
? ? 3.8 單行注釋用#
? ? ? ? #下面將學(xué)習(xí)列表
? ? 3.9 列表
????????bicycles=['trek','cannondale','redline','specialized']?
????????print(bicycles[0])? ? //? ? 索引從0開始
????????print(bicycles[-1])? ? //返回列表最后一個元素。同理-2返回倒數(shù)第二個......
? ? ? ? 3.9.3 修改列表元素
????????????motorcycles=['honda','yamaha','suzuki']
????????????print(motorcycles)
????????????motorcycles[0]='ducati'
????????????print(motorcycles)
? ? ? ? 3.9.2 添加列表元素
? ? ? ? ? ? ?motorcycles.append('awog')? ? //用append()函數(shù)
????????3.9.3 在列表中插入元素
????????????motorcycles.insert(1,'sdfog')? ? //在1處插入新元素
????????3.9.4 刪除列表元素
????????????del motorcycles[0]? ? //刪除第一個列表元素
????????3.9.5 pop()刪除棧頂元素
????????????popped_motorcycle=motorcycles.pop()? ? ?//刪除列表末尾即彈出棧頂元素
????????????popped_motorcycle=motorcycles.pop(2)? ? //刪除列表中任何位置的函數(shù)
? ? ? ? ? ? 刪除判斷標(biāo)準(zhǔn):若不再以任何方式使用,就用del語句;若刪除后還要繼續(xù)使用,就用方法? ?????pop()
????????3.9.6 根據(jù)值刪除元素
????????????motorcycles.remove('suzuki')? ? //刪除一個指定的值