一.格式化输出

%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. CRM WEB UI 02搜索跳转到详细界面

    结合上一个,在上一个中,创建的是选择链接字段EBELN. 下面来实现点击EBELN跳转到详细界面: 1.创建ZLYTEST03_H组件,做详细界面. 2.创建概览页 DETOV. 3.创建视图集 DE ...

  2. 利用sqlldr从MySQL导出一张表数据到Oracle

    根据业务需求,需要从MySQL库中同步一张表tap_application到Oracle中,下面是记录的导入过程. 1. 查看MySQL表结构 desc tap_application; +----- ...

  3. 用SQL命令手工创建CDB

    1.设置环境变量  $ export ORACLE_SID=ora12c  $ export ORACLE_HOME=/home/oracle/product/12.1.0/db1  $ export ...

  4. vue-router 按需加载

    vue的单页面(SPA)项目,必然涉及路由按需的问题.以前我们是这么做的 //require.ensure是webpack里面的,这样做会将单独拉出来作为一个chunk文件 const Login = ...

  5. MongoDB,无模式文档型数据库简介

    MongoDB的名字源自一个形容词humongous(巨大无比的),在向上扩展和快速处理大数据量方面,它会损失一些精度,在旧金山举行的MondoDB大会上,Merriman说:“你不适宜用它来处理复杂 ...

  6. ntpd修改版本号教程

    1.查看当前ntpd版本号 执行:ntpd -v 2.查看当前ntpd位置 执行:which ntpd 3.备份ntpd 执行:cp /usr/sbin/ntpd /usr/sbin/ntpd.bak ...

  7. LY.JAVA面向对象编程思想概述

    面向对象 2018年7月5日  逆袭之旅DAY09 2018年7月5日  逆袭之旅DAY09 2018-07-07

  8. learning ddr mode register MR1

  9. Linux command automake

    Linux command automake [Purpose]        Learning linux command automake for generate Makefile.in for ...

  10. bzoj1045

    题解: 随便推一下公式 然后发现是中位数 代码: #include<bits/stdc++.h> using namespace std; ],n; long long sum; int ...