跳至正文
-
Subscribe to our newsletter & never miss our best posts. Subscribe Now!
小奥的学习笔记

万丈高楼平地起,勿在浮沙筑高台

小奥的学习笔记

万丈高楼平地起,勿在浮沙筑高台

  • 首页
  • Sample Page
  • 隐私策略
  • GuestBook
  • 慕课课程(MOOC’s Lessons)
  • Footprints
  • About Me
  • 个人履历
  • 首页
  • Sample Page
  • 隐私策略
  • GuestBook
  • 慕课课程(MOOC’s Lessons)
  • Footprints
  • About Me
  • 个人履历
关

搜索

  • https://www.facebook.com/
  • https://twitter.com/
  • https://t.me/
  • https://www.instagram.com/
  • https://youtube.com/
Subscribe
Python

Python chapter 5 learning notes

作者 yszhang
2017年10月13日 1 分钟阅读
0
  1.  一个简单例子

    在python中,检查是否相等时,大小写不同默认是不相等的。如果需要不考虑大小写,则可把他们都统一转换成小写。

    检查多个条件时有以下两种情况:

    1. 必须同时符合多种情况:利用and语句。例如:if (age_0>21) and (age_1<=40)

    2. 多种情况符合其一即可:用or。例如:

if (age_0<18) or (age_1>60)

        如果你希望检查一个元素是否存在于一个列表中,可以使用in,如例所示:

>>>  requested_toppings=['mushrooms','onions','pinepple']

>>> 'mushrooms' in requested_toppings

屏幕显示Ture。

如果你希望检查一个元素不存在于一个列表中,可以使用 not in。如例所示:

>>> 'apple' not in requested_toppings

答案为True。

作者

yszhang

关注我
其他文章
上一个

安装pygame步骤

下一个

Python chapter 6 learning notes

暂无评论!成为第一个。

发表回复 取消回复

您的邮箱地址不会被公开。 必填项已用 * 标注

Copyright 2026 — 小奥的学习笔记. All rights reserved. Blogsy WordPress Theme