一.格式化输出

%s: 字符串的占位符, 可以放置任何内容(数字)
%d: 数字的占位符
age="18"
name="小明"
print("我叫%s"% "小明")
print("我叫%s,今年%s岁" % (name,age) )

二.常见运算符

计算机常用的数据
print(2**0) # 代表2的0次方
print(2**1) #2的一次方
print(2**2) #同上
print(2**3)
print(2**4)
print(2**5)
print(2**6)
print(2**7)
print(2**8)
print(2**9)
print(2**10) 赋值运算.
a = 10
a += 20 # 相当于a = a + 20
print(a) print(not not not not not not False) (and ,or, not) 同时存在. 先算括号, 然后算not, 然后算and , 最后算or
print(3>4 or 4<3 and 1==1) # False print(1 < 2 and 3 < 4 or 1>2 ) # T
print(2 > 1 and 3 < 4 or 4 > 5 and 2 < 1) # T
print(1 > 2 and 3 < 4 or 4 > 5 and 2 > 1 or 9 < 8) # F
print(1 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6)
print(not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) # F x or y 如果x==0 那么就是y, 否则是x
print(1 or 2) #
print(2 or 3) #
print(0 or 3) #
print(0 or 4) # print(0 or 1 or 3 or 0 or 5) #
print(1 and 2) #
print(2 and 0) #
print(0 and 3) #
print(0 and 4) # print(0 or 4 and 3 or 7 or 9 and 6) print(2 > 3 and 3) # false相当于0
print(2 < 1 and 4 > 6 or 3 and 4 > 5 or 6)#结果可能是数字也可能是True和False

python day02--运算符,编码的更多相关文章

  1. Python基础篇(格式化输出,运算符,编码):

    Python基础篇(格式化输出,运算符,编码): 格式化输出: 格式:print ( " 内容%s" %(变量)) 字符类型: %s  替换字符串      %d 替换整体数字  ...

  2. 学习笔记之Python最简编码规范

    Python最简编码规范 - 机器学习算法与Python学习 https://mp.weixin.qq.com/s/i6MwvC4jYTE6D1KHFgBeoQ https://www.cnblogs ...

  3. Python 常用 PEP8 编码规范

    Python 常用 PEP8 编码规范 代码布局 缩进 每级缩进用4个空格. 括号中使用垂直隐式缩进或使用悬挂缩进. EXAMPLE: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 ...

  4. Python学习 之三 Python基础&运算符

    第三章:Python基础 & 运算符 3.1 内容回顾 & 补充 计算机基础 编码 字符串: "中国" "Hello" 字 符: 中 e 字 节 ...

  5. 23.Python位运算符详解

    位运算符通常在图形.图像处理和创建设备驱动等底层开发中使用.使用位运算符可以直接操作数值的原始 bit 位,尤其是在使用自定义的协议进行通信时,使用位运算符对原始数据进行编码和解码也非常有效. 位运算 ...

  6. python基础之编码问题

    python基础之编码问题 本节内容 字符串编码问题由来 字符串编码解决方案 1.字符串编码问题由来 由于字符串编码是从ascii--->unicode--->utf-8(utf-16和u ...

  7. Python基础-字符编码与转码

    ***了解计算机的底层原理*** Python全栈开发之Python基础-字符编码与转码 需知: 1.在python2默认编码是ASCII, python3里默认是utf-8 2.unicode 分为 ...

  8. Python基本运算符

    Python基本运算符 什么是操作符? 简单的回答可以使用表达式4 + 5等于9,在这里4和5被称为操作数,+被称为操符. Python语言支持操作者有以下几种类型. 算术运算符 比较(即关系)运算符 ...

  9. python中的编码问题:以ascii和unicode为主线

      1.unicode.gbk.gb2312.utf-8的关系 http://www.pythonclub.org/python-basic/encode-detail 这篇文章写的比较好,utf-8 ...

  10. python与字符集编码

    讲的比较明白的博客:http://www.cnblogs.com/huxi/archive/2010/12/05/1897271.html 以上面博文的汉为例子,汉字的GBK编码是baba, UNIC ...

随机推荐

  1. 笔记react router 4(五)

    或许,你觉得我麻烦,明明一篇文章可以搞定的内容,非要写几篇.是不是正在吐槽我?没关系,我的目的达到了.手动傲娇( ̄∇ ̄) 然后,我们就要来聊一聊withRouter了. 我们都知道,当我在访问路由配置 ...

  2. leetcode-algorithms-35 Search Insert Position

    leetcode-algorithms-35 Search Insert Position Given a sorted array and a target value, return the in ...

  3. Spring ApplicationListener使用方法及问题

    使用场景 在一些业务场景中,当容器初始化完成之后,需要处理一些操作,比如一些数据的加载.初始化缓存.特定任务的注册等等.这个时候我们就可以使用Spring提供的ApplicationListener来 ...

  4. 第2天【OS Linux发行版介绍、Linux系统基础使用入门、Linux命令帮助、Linux基础命令】

    Logout    退出系统 Gedit     文本编辑器工具 Uname –r 查看内核版本信息,uname –a 比较详细 Cat /proc/cpuinfo      查看CPU Cat /p ...

  5. vscode代码保存时自动格式化成ESLint风格(支持VUE)

    一.问题 vscode的默认的代码格式化ctrl+shift+f 无法通过eslint的代码风格检查是一个非常蛋疼的问题 同样在进行vue项目开发的时候,使用eslint代码风格检查是没啥问题的,但是 ...

  6. which/whereis/locate/find的区别

    which--在$PATH目录下查找文件 whereis--在预定目录下(whereis -l查看)查找文件 locate--在数据库中查找目录或文件 find--遍历目录查找文件 说明: 1.关于w ...

  7. Struts初步入门(四)

    1.默认Action-深入Struts struts.xml 文件: <struts> <package name="default" namespace=&qu ...

  8. span 超出部分换行

    span{ word-break: normal; width: auto; display: block; white-space: pre-wrap; word-wrap: break-word; ...

  9. 逆袭之旅DAY16.东软实训.Oracle.索引

    2018-07-12 14:44:27 四.索引1.创建索引手动创建:create index 索引名 on 表名(列名,[列名,...])create table employee(pno numb ...

  10. learning ddr mode reigsters

    For application flexibility, various functions, features, and modes are programmable in four Mode Re ...