python 基础(格式化输出和编码)

1. 格式化输出
# %(占位) s(字符串) d(数字)
(1)msg = "我叫$s,今年%d,身高%d,学习进度为3%%" %(name,age,height)

 

2. while else
#当while被break打断,就不走else
当while不被break打断,就走else

 

3. 编码
(1)电脑传输和保存,都是存储 01010101 ascii码
01010101 8位 == 1个字节
1024字节 == 1kb
1024kb == 1MB
1个字节表示所有英文
(2)万国码(unicode)
一个中文4个字节
(3)utf-8
一个中文3个字节
(4)gbk(国内使用)
一个中文2个字节

 

4. 运算
and or not(取反)
优先级 not > and > or

a = False
if not a:
    print('1')

a = 5
b = [1, 2, 3]
if a not in b:
    print "hello"
View Code

 


posted @ 2021-08-08 19:08  hbfengj  阅读(117)  评论(0)    收藏  举报