2.1 运行
2.2 变量
message = "hello"
print(message)
2.2.1 变量的命名和使用
2.2.2 使用变量是避免命名错误
2.3 字符串
“Hello”
‘Hello’
“Hello ‘zhaohu’”
'this is "dog"! '

2.3.1 使用方法修改字符串的大小写
name = "My name is zhao"
print(name.title())
name.upper()
name.lower()

2.3.2 合并(拼接)字符串
first_name = "zhaohu"
last_name = "hu"
full_name = first_name + " "+last_name
print(full_name)

2.3.3 使用制表符或换行符来添加空白
\t \n

2.3.4 删除空白
rstrip();确保字符串末尾没有空格

2.3.5 使用字符串时避免语法错误

message = "One of Python's strengths is its diverse community"
print(mssage)
此处的字符串只能使用双引号。

2.4 数字
2.4.1 整数
+ - * / **(乘方)

2.4.2 浮点数

2.4.3 使用函数str()避免类型错误
age = 23
message = "Happy" + str(age) + "rd Birthday"
print(message)

2.4.4 Python 2中的整数
3.0/2 = 1.5 3/2 = 1 (Python3: 3/2=1.5)

2.5 注释
2.5.1 如何编写注释
# This is note

最新文章

  1. MySQL: Tree-Hierarchical query
  2. [转]输出带颜色的shell
  3. Hacker communities collection
  4. splay总结
  5. .net 大文件上传注意,修改 IIS 配置
  6. VMware简介
  7. .Net用js实现aspx页面删除TextBox输入框的前后空格
  8. < meta > 元素(转)
  9. Oracle 12C 简介
  10. Jsp页面获取项目名称
  11. UIScrollView 和 UICollectionView 分页效果
  12. poj 3522 Kruskal
  13. JWT实战:使用axios+PHP实现登录认证
  14. py文件2种执行方式
  15. Day9 轨道角动量
  16. 支持pc和移动端的手写签批功能
  17. 字体图标-把SVG图标转换成所需要的字体图标
  18. vue 组件动态 循环
  19. String 常用方法
  20. map内置函数分析所得到的思路

热门文章

  1. Spring Cloud Sleuth进阶实战
  2. TJU Problem 1065 Factorial
  3. DoTween可视化编程用法详解
  4. CTF之栅栏密码
  5. frameset的用法
  6. 数据库表结构转成设计书,PowerDesigner 表格导出为excel
  7. 系统有专门画图的api
  8. MySQL--MODIFY COLUMN和ALTER COLUMN
  9. leetcode:Maximum Depth of Binary Tree【Python版】
  10. smarty学习——编程知识