小尹学python

导航

2021年9月28日 #

Python:运算优先级

摘要: # 算数运算符优先级(+-*/等)> 比较运算符(>,<,=)优先级 > 逻辑运算符(not,and,or) # 逻辑运算符中,not > and > or # 不确定,可以加() if not 1 and 1 + 3 > 2 or 3 == 8: print(True) else: print(F 阅读全文

posted @ 2021-09-28 17:34 小尹学python 阅读(195) 评论(0) 推荐(0)

Python:运算符

摘要: + :相加 x = 10 , y = 2 ,x +y = 12 - : 相减 x = 10 , y = 2 ,x -y = 10 * : 相乘 x = 10 , y = 2 ,x * y = 20 / : 相除 x = 10 , y = 2 ,x / y = 5 % : 去余数 x = 11, y 阅读全文

posted @ 2021-09-28 17:27 小尹学python 阅读(26) 评论(0) 推荐(0)

Python:字符串格式化

摘要: name = 'alen' age = 18 print(f"my name is {name},my age is {age}") # f表示法,新版本 print("my name is %s,my age is %s"%(name,age)) # %s表示法,前面%s根据顺序获取变量,如果打印 阅读全文

posted @ 2021-09-28 17:18 小尹学python 阅读(34) 评论(0) 推荐(0)

Python:while-else(用处不大)

摘要: num = 1 while num < 10: print(f'数字为{num},小于10') num += 1 else: print(f'数字为{num},数字等于10')# 当while条件成立时,运行while语句下内容,否则运行else语句下内容 阅读全文

posted @ 2021-09-28 17:07 小尹学python 阅读(84) 评论(0) 推荐(0)