1、python3→help()→keywords
false
defif
raise
trure
delimport
return
none
elif
intry
andelse
iswhile
a***cept
lambda
with
asssert
finally
nonlocal
yield
break
fornot
class
from
orcontinue
global
pass
2、python中不需要為變數指定型別(自動識別)
python可以操作字串(用引號括起來 )
3、python3 怎樣從鍵盤讀取輸入
通常情況下,python 的**中是不需要從鍵盤讀取輸入的。不過我們還是可以在 python 中使用函式 input() 來做到這一點,input() 有乙個用於列印在螢幕上的可選字串引數,返回使用者輸入的字串。如何理解input()
我們設 y = input(「對使用者的提示資訊」)
則 y 是使用者鍵入的字元
自動填入程式**中
number = int(input("enter an integer: "))
使用者看到的**介面是這樣的:
enter an integer:(使用者鍵入與提示資訊相符的字元,假設鍵入390)
返回**程式:
number = int(390)
就這麼理解吧:
y=input("enter an integer: ")
是乙個函式
"enter an integer: " = 函式的定義域
y = 函式的值域
4、python3 字串的格式化
print("year {} rs. ".format(year, value))
"year {} rs. ".format(year, value)
稱為字串格式化,大括號和其中的字元會被替換成傳入str.format()
的引數,也即 year 和 value。其中 的意思是替換為 2 位精度的浮點數。
例如:year 1 rs. 11400.00
year 2 rs. 12996.00
year 3 rs. 14815.44
year 4 rs. 16889.60
year 5 rs. 19254.15
5、元組封裝和拆封
data = ("linux", "china", "python")# 元組封裝
name, country, language = data# 元組拆分
name
'linux'
country
'china'
language
'python'
ps:學習一定要及時記錄反饋堅持就是勝利!!
從零開始學習python(一)
來自嵩天老師的python 程式設計 字串的表示方法 字串使用 乙個 多個 切片 字串中的特殊字元 字串操作符 字串處理方法 字串格式化 format 1.字串的表示方法操作符及其使用 描述x y 連線字串x y nx或xn 複製n次字串x x in s 如果x是s的字串,返回true 注意大寫 否...
從零開始學習人工智慧 python篇 (二)
mac 系統自帶python,本人系統為macos high sierra,版本為10.13.3,在終端輸入指令python v 獲得到的python版本為 2.7.15,所以mac系統是自帶python的。但是2020 年 1 月 1 日,官方宣布停止 python 2 的更新。所以本著要玩就玩最...
學習python之路 入門篇A
偶爾經同事的介紹進入了金角大王的部落格裡,看到大王編寫的文章都是關於python程式設計的,由於自己一直也是做軟體測試方面的工作,也一直想往自動化測試方面發展,了解到利用python可以進行自動化測試操作,可以減少人工測試的繁鎖操作。讀了python的基礎篇了解了python的發展歷史及python...