1. 程式人生 > >第三天筆記

第三天筆記

對不起 取反 非法字符 字節 comm 電腦 break gbk 所有

一,初始編碼。
電腦的傳輸,還有儲存的實際上都是01010101010
美國:ascii碼 一共8位,包括數字、英文、特殊字符在內的共128個符號,每個字符占一個字節,第一位為0。
unicode萬國碼:包含中文在內的所有語言的字符,用4個字節共32位表示一個字符。
utf-8經過優化的萬國碼:使用3個字節共24位表示一個字符。
gbk國內所用的編碼方式,一個中文占2個字節。
8bit=1byte
1024byte=1kb
1024kb=1mb
1024mb=1gb
1024gb=1tb


設置一個輸入3次的登錄密碼,如果輸入錯誤在給3次機會。
username = "congcong"
password = "123"
i = 0
while i < 3:
name = input("請輸入你的用戶名")
pwd = input("請輸入你的密碼")
if username == name and password == pwd:
print(‘您登錄成功‘)
break
else:
print("登錄失敗,您還有%d次機會"%(2-i))
if (2-i) == 0:
result = input("是否還想再試試?Yes")
if resule == "Yes":
i = 0
continue
i += 1
else:print("呵呵")

in, not in
s1 = "abcd"
print(‘a‘ in s1)
print(‘ag‘ in s1)
print(‘ad‘ not in s1)
comment = input(‘請輸入你的評論:‘)
if (‘習大大‘in comment) or (‘國民黨‘in comment) or( ‘蔣介石‘ in comment):
print(‘對不起您輸入的有非法字符,請重新輸入‘)
else:print(‘評論成功‘)
# and 且,前後為真才為真。
# or 或,有一為真,就為真。
# not 非。取反。

第三天筆記