日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python全栈开发内容_Python全栈开发之Day02

發布時間:2023/12/1 python 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python全栈开发内容_Python全栈开发之Day02 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一. 回顧上節主要內容

1. python是一門解釋型弱類型高級語言

2. python的解釋器

CPython, PyPy, JPython, IronPython, Ipython

3. print(內容1, 內容2)

4. 變量

程序運行過程中產生的中間值, 暫時存儲在內存中.供后面的程序使用

命名規范:

1. 由字母, 數字, 下戶線組成

2. 不能是數字開頭, 更不能是純數字

3. 不能使用關鍵字

4. 不要太長

5. 要有意義

6. 區分大小寫

7. 不要用中文

8. 推薦使用駝峰或下劃線

5. 類型

1. int整數,

2. str字符串, ?',",''',"""

3. bool布爾. True, False

6. input() 用戶交互, 獲取的內容是字符串類型

7. if語句

if 條件:

代碼塊

if 條件:

代碼塊

else:

代碼塊

if 條件:

代碼塊

elif 條件:

代碼塊

elif....

else:

代碼塊

if 條件:

if 條件:

...

else:

else:

二. 今日主要內容

1. 循環

while 條件:

代碼塊(循環體)

else:

當上面的條件為假. 才會執行

執行順序:

判斷條件是否為真. 如果真. 執行循環體. 然后再次判斷條件....直到循環條件為假. 程序退出

2. break和continue

break: 停止當前本層循環

continue: 停止當前本次循環. 繼續執行下一次循環

3. 格式化輸出

%s 占位字符串

%d 占位數字

4. 運算符

and: 并且, 兩端同時為真. 結果才能是真

or: 或者, 有一個是真. 結果就是真

not: 非真既假, 非假既真

順序: () => not => and => or

x or y:

如果x是零, 輸出y

如果x是非零, 輸出x

True: 非零

False: 零

5. 編碼

1. ascii. 最早的編碼. 至今還在使用. 8位一個字節(字符)

2. GBK. 國標碼. 16位2個字節.

3. unicode. 萬國碼. 32位4個字節

4. UTF-8. 可變長度的unicode.

英文: 8位. 1個字節

歐洲文字:16位. 2個字節

漢字. 24位. 3個字節

8bit = 1byte

1024byte = 1KB

1024KB = 1MB

1024MB = 1GB

1024GB = 1TB

上接之前的02

03-while死循環:

#死循環

count = 1

while count <= 5:print("噴死你..")

count= count + 1

#數數 1-100

count= 1

while count < 101:print(count)

count= count + 2

#讓用戶一直去輸入內容, 并打印. 直到用戶輸入q的時候退出程序

whileTrue:

content= input("請輸入一句話,(輸入q退出程序):")if content == 'q':break #打斷. 終止當前本層循環

print(content)

flag=Truewhileflag:

content= input("請輸入一句話,(輸入q退出程序):")if content == 'q':

flag= False #打斷. 終止當前本層循環

print(content)else:print("123")whileTrue:

content= input("請輸入一句話,(輸入q退出程序):")if content == 'q':continue #停止當前本次循環. 繼續執行下一次循環

print(content)

break和continue的區別: break是徹底的停止掉當前層循環. continue停止當前本次循環,繼續執行下一次循環

count= 1

while count <= 10:if count == 4:

count= count + 1

continue #用來排除一些內容

print(count)

count= count + 1

#必須要寫

count = 1

while count <= 20:if count == 10:break #不會觸發else的執行, while...else...是一個整體. break的時候徹底的停止這個整體

print(count)

count= count + 1

else: #當上面的條件不成立的時候執行這個else中的代碼

print("數完了")

04-格式化輸出:

name="alex"age= 38hobby= "浪"location= "湖邊"

#print(age+"歲的"+name+"在"+location+"喜歡"+hobby) ##格式化#%s 占位. 占位的是字符串, 全能的. 什么都能接#%d 占位. 占位的是數字

print("%s歲的%s在%s喜歡%s" %(age, name, location, hobby))

name= input("請輸入名字:")

age= input("請輸入年齡:")

job= input("請輸入你的工作:")

hobby= input("請輸入你的愛好:")#s = '''------------ info of %s -----------#Name : %s#Age : %s#job : %s#Hobbie: %s#------------- end -----------------''' % (name, name, age, job, hobby)

print(s)

name= 'sylar'

#如果你的字符串中出現了%s這樣的格式化的內容. 后面的%都認為是格式化.如果想要使用%. 需要轉義 %%

print("我叫%s, 我已經學習了2%%的python了" %(name))print("我叫周潤發. 我已經活了50%了")

05-簡單基本運算:

print(1+1)print(1-1)print(1*2)print(1/2)print(10%3) #計算余數 10/3=3......1

n= 49

if n % 2 == 1:print("奇數")else:print("偶數")print(10//3) #整除. 地板除. 計算商

print(5**3) #5的2次冪 m**n m的n次冪

a= 10b= 20

print(a == b) #等于

print(a != b) #不等于

a= 1b= 2a+= b #a = 3 a+=b => a = a + b#a *= b => a = a * b

print(a)print(b)

06-邏輯運算:

#1. and 并且的含義. 左右兩端同時為真. 結果才能是真.#2. or 或者的含義. 左右兩端有一個是真. 結果就是真. 所有的條件都是假. 結果才是假#3. not 取反 非真既假, 非假既真#順序: () => not => and => or 相同的運算. 從左往右算

print(1>2 and 4<6 or 5>7)print(1 > 2 or 3 > 4)print(5>3 or 4<6)print(5>3 or 4>6)print(3>4 or 4<3 and 1==1) #False

print(1 < 2 and 3 < 4 or 1>2 ) #True

print(2 > 1 and 3 < 4 or 4 > 5 and 2 < 1) #True

print(1 > 2 and 3 < 4 or 4 > 5 and 2 > 1 or 9 < 8) #False

print(1 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) #False

print(not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) #False

xory 如果x是0 返回y, 如果x是非零, 返回xprint(1 or 2) #1

print(1 or 0) #1

print(0 or 1) #1

print(0 or 2) #2

print(0 or 1 or 2 or 3)print(3 or 0 or 1 or 0 or 2)

and和or相反. 不要去總結and. 記住orprint(1 and 2) #2

print(0 and 2) #0

print(1 and 0) #0

print(0 and 1) #0

print(1 and 2 or 3)print(1 or 2 and 3)

False: 0, True:1(非零)print(1 and 2>3)print(2>3 and 1)print(1 > 2 or 0 and 3 < 6 or 5) #先算and 后算or

print(2**32)

07-in和not in:

content = input("請輸入你的評論:")if "馬化騰" not incontent:print("你的言論不和諧")else:print(content)

總結

以上是生活随笔為你收集整理的python全栈开发内容_Python全栈开发之Day02的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。