python学习之旅-02

1、while 循环

语法:

  while 条件:

    循环体

  else:

    当条件不成立时执行这里;  注意break直接退出,不会执行else部分

break:终止当前循环

continue:停止当前本次循环。 继续执行下一次循环

2、格式化输出

%s 占位符;占位字符串

%d 占位数字

3、运算符

and 并且,左右两端同时为真。结果才能为真

or  或者,左右两端有一个是真,结果就为真

not  非真即假,非假即真

优先级: ()-> not -> and -> or

or : if x == 0 then y else x

and: 相反

4、字符串编码
  1. ASCII 8bit 1byte
  2. GBK 16bit 2byte
  3. Unicode 32bit 4byte
  4. UTF-8 可变长度的unicode
  英文: 8bit 1byte
  欧洲文字; 16bit 2byte
  中文 :24bit 3byte

5、in 和 not in
  in 判断xxx是否在xxx中..

猜你喜欢

转载自www.cnblogs.com/dandanouni/p/12530355.html