摘要:
# 十、python字符串str ## 1.字符串的定义与输入 在python中,用引号引起来的都是字符串。还有input函数输入的, str()函数转换的等。 ``` string1="hello" string2='hello' string3="""hello python""" string 阅读全文
摘要:
# 九、python循环语句 ## 1.for循环 for循环遍历一个对象(比如数据序列,字符串,列表,元组等),根据遍历的个数来确定循环次数。 for循环可以看作为定循环,while循环可以看作为不定循环。 **for循环的基本格式** ``` for 变量 in 数据: 重复执行的代码 ``` 阅读全文
摘要:
# 八、python判断语句 ## 1.python单分支判断语句: ``` if 条件: # 条件结束要加:号(不是;号) 执行动作一 # 这里一定要缩进(tab键或四个空格),否则报错 # 没有fi结束符了,就是看缩进 ``` ## 2.python双分支判断语句: ``` if 条件: 执行动 阅读全文
摘要:
# 七、python运算符 ## 1.算术运算符 |算术运算符|描述|实例| | | | | +| 加法| 1+2=3 -|减法| 5-1=4 *|乘法 |3*5=15 / |除法 |10/2=5 // |整除 |10//3=3 不能整除的只保留整数部分 \**|求幂|2\**3=8 %|取余|10 阅读全文
摘要:
# 六、python输入输出 ## 1.输入 ``` python里的input输入用法 name=input("what is your name: ") age=input("what is your age: ") # input输入的直接就为str类型,不需要再str()转换了 print( 阅读全文
摘要:
# 五、Python基本数据类型分类 ## 1.基本数据类型 **(1) 数字** int 整型(1, 2, -1, -2) float 浮点型(34.678) bool 布尔型(True/False) complex 复数(4+3J, 不应用于常规编程,这种仅了解一下就好 **(2)字符串** s 阅读全文
摘要:
# 三、python注释 **1.单行注释: # 被注释内容** 在# 后面建议添加一个空格 ,然后在写注释的内容  # 帮助方法 print("hello world") print("python") # 这是两句分开的打印,会打印两行 print("hello world\npython") # 打印的结果会换 阅读全文
摘要:
# 一、第一个python脚本 ## 1. 使用vi或vim直接写 ``` # vim 1.py #!/usr/bin/python # 声明类型,指明解释器命令路径 #-*- coding: utf-8 -*- # 指定字符格式为utf-8(可以打印中文),python3不用再指定了 print 阅读全文