python 基础(2)[编程语言教程]

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”

python 基础(2)

原文:https://www.cnblogs.com/hbfengjun/p/15115836.html

hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 » python 基础(2)