格式化輸出:
佔位符:%
字符類型:s
數字類型: d
在格式輸出時要用百分號:%%
#格式化輸出 #% s d """ name = input('請輸入你姓名') age = input('請輸入年齡') height = input('請輸入身高') msg = '我叫%s, 今年%s 身高%s'%(name,age,height) print(msg) name = input('請輸入你的名字') age = input('請輸入你的年齡') job = input('請輸入你的職業') hobbie = input('請輸入你的愛好') msg = '''------------ info of %s ----------- Name : %s Age : %d job : %s Hobbie: %s ------------- end -----------------''' % (name, name, int(age), job, hobbie) print(msg) name = input('請輸入你姓名') age = input('請輸入年齡') height = input('請輸入身高') msg = '我叫%s, 今年%s 身高%s 學習進度 3%%'%(name,age,height) print(msg) """
編碼:
ascii只能顯示英文,特殊字符,數字
萬國碼:unicode 最開始16位,發現中文不夠變成32位(4個字節)
占用資源
升級:utf-8 utf-16 utf-32
utf-8:最少用一個字節,8位表示一個英文
歐洲16位,2個字節
亞洲24位, 3個字節
gbk:中國國產,只能用於中文和ascii碼的文字
While else:
如果有break不執行else
count = 0 while count <= 5: count += 1 if count == 3: break print("Loop" , count) else: print('循環正常執行完啦') print("----- out of while loop -----")
邏輯運算:
and or not 優先級 :not > and > or
非零轉化成bool是True 零轉化成bool是False
X or Y X是True 則返回X X是False則取Y
XandY 與 XorY 相反