* { margin: 0; padding: 0; } .about { width: 100%; height: 100%; overflow: hidden; } .about_bgc { width: 100% } .about_tit { position: absolute; top: 280px; left: 0; right: 0; font-size: 28px; font-weight: 550; bottom: 0; width: 800px; margin: auto; text-align: center; } .ribbon { display: flex; justify-content: center; position: absolute; right: 300px; top: 50px; margin: auto; } .ribbon:after, .ribbon:before { margin-top: 0.5em; content: ""; display: flex; ; border: 1.5em solid #fff; } .ribbon:after { border-right-color: transparent; } .ribbon:before { border-left-color: transparent; } .ribbon a:link, .ribbon a:visited { color: #000; text-decoration: none; height: 3.5em; overflow: hidden; } .ribbon span { background: #fff; display: inline-block; line-height: 3em; padding: 0 1.5em; margin-top: 0.5em; position: relative; -webkit-transition: background-color 0.2s, margin-top 0.2s; /* Saf3.2+, Chrome */ -moz-transition: background-color 0.2s, margin-top 0.2s; /* FF4+ */ -ms-transition: background-color 0.2s, margin-top 0.2s; /* IE10 */ -o-transition: background-color 0.2s, margin-top 0.2s; /* Opera 10.5+ */ transition: background-color 0.2s, margin-top 0.2s; } .ribbon a:hover span { background: #FFD204; margin-top: 0; } .ribbon span:before { content: ""; position: absolute; top: 3em; left: 0; border-right: 0.5em solid #9B8651; border-bottom: 0.5em solid #fff; } .ribbon span:after { content: ""; position: absolute; top: 3em; right: 0; border-left: 0.5em solid #9B8651; border-bottom: 0.5em solid #fff; } .me { display: flex; justify-content: center; margin-top: 60px; overflow: hidden; } .me_tit { width: 600px; line-height: 36px; font-size: 18px; margin-left: 100px; margin-top: 50px; } .me_img { width: 800px; height: 600px; } .animate { padding-left: 20px; width: 500px; font-size: 16px; color: #000; animation: 10s wordsLoop linear infinite normal; } @keyframes wordsLoop { 0% { transform: translateY(100px); -webkit-transform: translateY(100px); } 100% { transform: translateY(-100%); -webkit-transform: translateY(-100%); } } .videos { display: flex; margin-top: 60px; padding-bottom: 80px; } .videos span { width: 400px; margin-right: 100px; margin-left: 300px; color: #FFD204 }

python笔记4(控制语句)

控制语句

一:选择结构

A:单分支结构

if(条件语句):
(缩进)结果
缩进:pytharm中默认四个空格=TAB键

例:
a = input("请输入一个小于10的数:")
if int(a)<10:
print(a)

运行结果:
image

  • 条件表达式详解
    表达式为false的情况
    false,0,0.0,空值None,空序列对象(空列表,空元祖,空集合,空字典,空字符串),空range对象,空迭代对象
    其他情况均为Ture

  • 条件表达式中,不能有赋值操作符“=”

B:双分支选择结构

if 条件表达式:
。。。。语句1/语句块1
else:
。。。。语句2/语句块2

例:
a = input("请输入一个数字:")

if int(a)<10:
print("a是一个小于10的数字")
else:
print("a是一个大于等于10的数字")

结果:
image

三元条件运算符

格式:
结果1 if 判断语句 else 结果2

例:
print("a小于10的数" if int(a)<10 else "a是大于等于10的数")
与上面同等效果

C:多分支结构

观看54

posted @ 2023-03-28 14:48  #鲁班一号#  阅读(31)  评论(0)    收藏  举报