php网站开发最新需求,网站维护要做哪些工作,百度一下 你就知道官方,邯郸做网站推广的地方一. 回顾上节主要内容1. python是一门解释型弱类型高级语言2. python的解释器CPython, PyPy, JPython, IronPython, Ipython3. print(内容1, 内容2)4. 变量程序运行过程中产生的中间值, 暂时存储在内存中.供后面的程序使用命名规范:1. 由字母, 数字, 下户线组成2. 不能是数字开…一. 回顾上节主要内容1. python是一门解释型弱类型高级语言2. python的解释器CPython, PyPy, JPython, IronPython, Ipython3. print(内容1, 内容2)4. 变量程序运行过程中产生的中间值, 暂时存储在内存中.供后面的程序使用命名规范:1. 由字母, 数字, 下户线组成2. 不能是数字开头, 更不能是纯数字3. 不能使用关键字4. 不要太长5. 要有意义6. 区分大小写7. 不要用中文8. 推荐使用驼峰或下划线5. 类型1. int整数,2. str字符串, ,,,3. bool布尔. True, False6. input() 用户交互, 获取的内容是字符串类型7. if语句if 条件:代码块if 条件:代码块else:代码块if 条件:代码块elif 条件:代码块elif....else:代码块if 条件:if 条件:...else:else:二. 今日主要内容1. 循环while 条件:代码块(循环体)else:当上面的条件为假. 才会执行执行顺序:判断条件是否为真. 如果真. 执行循环体. 然后再次判断条件....直到循环条件为假. 程序退出2. break和continuebreak: 停止当前本层循环continue: 停止当前本次循环. 继续执行下一次循环3. 格式化输出%s 占位字符串%d 占位数字4. 运算符and: 并且, 两端同时为真. 结果才能是真or: 或者, 有一个是真. 结果就是真not: 非真既假, 非假既真顺序: () not and orx or y:如果x是零, 输出y如果x是非零, 输出xTrue: 非零False: 零5. 编码1. ascii. 最早的编码. 至今还在使用. 8位一个字节(字符)2. GBK. 国标码. 16位2个字节.3. unicode. 万国码. 32位4个字节4. UTF-8. 可变长度的unicode.英文: 8位. 1个字节欧洲文字:16位. 2个字节汉字. 24位. 3个字节8bit 1byte1024byte 1KB1024KB 1MB1024MB 1GB1024GB 1TB上接之前的0203-while死循环:#死循环count 1while count 5:print(喷死你..)count count 1#数数 1-100count 1while count 101:print(count)count count 2#让用户一直去输入内容, 并打印. 直到用户输入q的时候退出程序whileTrue:content input(请输入一句话,(输入q退出程序):)if content q:break #打断. 终止当前本层循环print(content)flagTruewhileflag:content input(请输入一句话,(输入q退出程序):)if content q:flag False #打断. 终止当前本层循环print(content)else:print(123)whileTrue:content input(请输入一句话,(输入q退出程序):)if content q:continue #停止当前本次循环. 继续执行下一次循环print(content)break和continue的区别: break是彻底的停止掉当前层循环. continue停止当前本次循环,继续执行下一次循环count 1while count 10:if count 4:count count 1continue #用来排除一些内容print(count)count count 1#必须要写count 1while count 20:if count 10:break #不会触发else的执行, while...else...是一个整体. break的时候彻底的停止这个整体print(count)count count 1else: #当上面的条件不成立的时候执行这个else中的代码print(数完了)04-格式化输出:namealexage 38hobby 浪location 湖边#print(age岁的name在location喜欢hobby) ##格式化#%s 占位. 占位的是字符串, 全能的. 什么都能接#%d 占位. 占位的是数字print(%s岁的%s在%s喜欢%s %(age, name, location, hobby))name input(请输入名字:)age input(请输入年龄:)job input(请输入你的工作:)hobby input(请输入你的爱好:)#s ------------ info of %s -----------#Name : %s#Age : %s#job : %s#Hobbie: %s#------------- end ----------------- % (name, name, age, job, hobby)print(s)name sylar#如果你的字符串中出现了%s这样的格式化的内容. 后面的%都认为是格式化.如果想要使用%. 需要转义 %%print(我叫%s, 我已经学习了2%%的python了 %(name))print(我叫周润发. 我已经活了50%了)05-简单基本运算:print(11)print(1-1)print(1*2)print(1/2)print(10%3) #计算余数 10/33......1n 49if n % 2 1:print(奇数)else:print(偶数)print(10//3) #整除. 地板除. 计算商print(5**3) #5的2次幂 m**n m的n次幂a 10b 20print(a b) #等于print(a ! b) #不等于a 1b 2a b #a 3 ab a a b#a * b a a * bprint(a)print(b)06-逻辑运算:#1. and 并且的含义. 左右两端同时为真. 结果才能是真.#2. or 或者的含义. 左右两端有一个是真. 结果就是真. 所有的条件都是假. 结果才是假#3. not 取反 非真既假, 非假既真#顺序: () not and or 相同的运算. 从左往右算print(12 and 46 or 57)print(1 2 or 3 4)print(53 or 46)print(53 or 46)print(34 or 43 and 11) #Falseprint(1 2 and 3 4 or 12 ) #Trueprint(2 1 and 3 4 or 4 5 and 2 1) #Trueprint(1 2 and 3 4 or 4 5 and 2 1 or 9 8) #Falseprint(1 1 and 3 4 or 4 5 and 2 1 and 9 8 or 7 6) #Falseprint(not 2 1 and 3 4 or 4 5 and 2 1 and 9 8 or 7 6) #Falsexory 如果x是0 返回y, 如果x是非零, 返回xprint(1 or 2) #1print(1 or 0) #1print(0 or 1) #1print(0 or 2) #2print(0 or 1 or 2 or 3)print(3 or 0 or 1 or 0 or 2)and和or相反. 不要去总结and. 记住orprint(1 and 2) #2print(0 and 2) #0print(1 and 0) #0print(0 and 1) #0print(1 and 2 or 3)print(1 or 2 and 3)False: 0, True:1(非零)print(1 and 23)print(23 and 1)print(1 2 or 0 and 3 6 or 5) #先算and 后算orprint(2**32)07-in和not in:content input(请输入你的评论:)if 马化腾 not incontent:print(你的言论不和谐)else:print(content)