開發(fā)語言:
高級語言:Python Java、PHP C# Go ruby C++... ===》 字節(jié)碼
低級語言:C、匯編 ===》 機器碼
創(chuàng)新互聯(lián)的客戶來自各行各業(yè),為了共同目標,我們在工作上密切配合,從創(chuàng)業(yè)型小企業(yè)到企事業(yè)單位,感謝他們對我們的要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團隊有機會用頭腦與智慧不斷的給客戶帶來驚喜。專業(yè)領(lǐng)域包括成都網(wǎng)站設(shè)計、網(wǎng)站制作、電商網(wǎng)站開發(fā)、微信營銷、系統(tǒng)平臺開發(fā)。
語言之間的對比:
PHP類:適用于寫網(wǎng)頁,局限性
Python Java: 及可以寫網(wǎng)頁 也可以寫后臺功能
CPython
:是python的參考實現(xiàn),C編寫。
:把python編譯成中間態(tài)的字節(jié)碼,然后有虛擬機解釋。
PyPy
: 是用RPython實現(xiàn)的解釋器。
:特點是即時編譯(JIT Just In Time)
:旨在提高性能,同時保持最大兼容性,目前比CPython的速度快超過5倍。
Jython:
:是一個將python代碼編譯成java字節(jié)碼的實現(xiàn),運行在JVM上。
:它可以像使用Python模塊一樣,導(dǎo)入并使用任何Java類。
IronPython
: 是一個針對.NET框架的Python實現(xiàn)
:可以用Python和.NET famework的庫,也將Python暴漏給.NET框架中的其他語言。
1、第一句python
后綴名是可以是任意?
2、兩種執(zhí)行方式
python解釋器py文件路徑
python 進入解釋器:
實時輸入并獲取到執(zhí)行結(jié)果
3、解釋器路徑
#!/usr/bin/env python //linux 需要添加頭部,解釋器路徑
4、編碼
#-- coding:utf8 -- //python3中加不加入都無所謂 //python2中頭部添加,默認asics碼
常見編碼:
ASCII編碼(American Standard Code for Information Interchange,美國信息互換標準代碼) 使用7位或8位二進制組合128或256種可能的字符。
GBK編碼通稱他們叫做 “DBCS“(Double Byte Charecter Set 雙字節(jié)字符集)
unicode統(tǒng)一碼、萬國碼、ISO國際標準編碼方案 中文字符占兩字節(jié)
utf-8互聯(lián)網(wǎng)上使用最廣的一種unicode的實現(xiàn)方式,為傳輸而設(shè)計的編碼。特點:變長編碼方式、統(tǒng)一無國界 中文字符占3個字節(jié)
5、 input
input的用法,永遠等待,直到用戶輸入了值,就會將輸入的值賦值給一個東西
實例:
#!/usr/bin/env python
`# -*- coding:utf8 -*-`
n=input ('請輸入用戶名:')
print(n)
6、變量的條件
#變量名
字母
數(shù)字
下劃線
特例:
變量名不能以數(shù)字開頭
python關(guān)鍵字也不能使用命令
7、條件語句
a.
if 條件:
代碼塊 ==> 需要空格
else:
代碼塊 ==>需要空格
示例1:
if 1 == 1:
print('OK')
else:
print('error')
示例2:
if 1 == 2:
if 2 == 2:
print('歡迎進入1')
print('歡迎進入2')
else:
print('歡迎進入3')
else:
print('error')
b.
示例:多重判斷
if 條件:
代碼塊
elif 條件:
代碼塊
elif 條件:
代碼塊
else
print('xxx')
print ('xxx')
pass 代指空代碼,無意義,僅僅用于表示代碼塊
8、數(shù)據(jù)類型
字符串(引號)
name = "xx"
name = 'alex'
name = """alex"""
name = '''alex'''
9、運算符
加法:
n1 = "alex"
n2 = "sb"
n3 = n1 + n2
print (n3)
alexsb
乘法:
n1 = "alex"
n2 = n1 * 10
print(n2)
alexalex....alex
賦值:
age = 13
加減乘除
a1 = 10
a2 = 20
a3 = a1 + a2
a3 = a1 - a2
a3 = a1 * a2
a3 = a1 / a2
a3 = 4 ** 2 4的平方
a3 = 39 % 8 獲取39除以8得到的余數(shù)
a3 = 39 // 8 獲取39除以8得到的商 商等于4 四八、三十二
示例:
a3 = 39 / 8
a = 13
temp = 13 % 2
if temp == 0:
print("偶數(shù)")
else:
print("基數(shù)")
**10、循環(huán)**
while 循環(huán)
示例:
import time
while 1==1
print('ok',time.time())
注:條件滿足即打印
import 導(dǎo)入模塊
示例:
import time
count = 0
while count < 10:
print ('ok',time.time())
count = count + 1
print (123)
補充:
a.while else
示例:while 可以加條件判斷
count = 0
while count < 10:
print(count)
count = count + 1
else:
print('else')
b. continue 遇到continue就終止當前循環(huán),進入下一個循環(huán)
示例:0-9 不打印7
count = 0
while count < 10:
if count == 7:
count = count + 1
continue
print(count)
count = count + 1
c. break 遇到break就終止循環(huán)
count = 0
while count < 10:
count = count + 1
print(count)
break
print(11111)
print('end')
### 練習題:
#!/usr/bin/env python
#變量名 字母 數(shù)字 下劃線 特例:變量名不能以數(shù)字開頭 python關(guān)鍵字也不能使用命令
import time
count = 0
while count < 10:
print ('ok',time.time())
count = count + 1
print (123)
#1到100的和
count = 0
while count < 100:
count = count + 1
print ('count')
#1-100的基數(shù)
n = 1
while n < 101:
temp = n % 2
if temp == 0:
pass
else:
print(n)
n = n + 1
#1-100的偶數(shù)
n = 1
while n < 101:
temp = n % 2
if temp == 0:
print(n)
else:
pass
n = n + 1
#使用while循環(huán)輸入 1 2 3 4 5 6 8 9 10
n = 1
while n < 11:
if n == 7:
pass
else:
print(n)
n = n + 1
print ('----end---')
#求1-100的和
'''
n = 1
s = 0
while n < 101:
s = s + n
n = n + 1
print(s)
'''
#求1-2+3-4+5...99所有數(shù)的和
'''
n = 1
s = 0
while n < 100:
temp = n % 2
if temp == 0:
s = s - n
else:
s = s + n
n = n + 1
print(s)
'''
#打印0-9 但不打印7
'''
count = 0
while count < 10:
if count == 7:
count = count + 1
continue
print(count)
count = count + 1
'''
#用戶登陸(三次機會重試)
'''
count = 0
while count < 3:
user = input('user: ')
pwd = input('password: ')
if user == 'alex' and pwd == '123':
print('weclome')
print('......')
break
else:
print('pwd or user error')
count = count + 1
'''
當前題目:1daypython運算、循環(huán)、判斷筆記
本文地址:http://aaarwkj.com/article30/iidoso.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、企業(yè)網(wǎng)站制作、微信小程序、動態(tài)網(wǎng)站、網(wǎng)站建設(shè)、品牌網(wǎng)站設(shè)計
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)