C语言list怎么判断元素存在,Python3基础listinnotin判断一个变量是否在...
C语⾔list怎么判断元素存在,Python3基础listinnotin判断⼀个变
量是否在。。。
Python : 3.7.0
OS : Ubuntu 18.04.1 LTS
IDE : PyCharm 2018.2.4
Conda : 4.5.11
typesetting : Markdown
code
"""
@Author : ⾏初⼼
@Date : 18-9-23
@Blog : wwwblogs/xingchuxin
@Gitee : gitee/zhichengjiu
"""
def main():
members = ['北⽃阳明贪狼星', '北⽃阴精巨门星', '北⽃真⼈禄存星', '北⽃⽞冥⽂曲星', '北⽃丹元廉贞星', '北⽃北极武曲星', '北⽃天关破军星']
# '北⽃阳明贪狼星' 在列表中吗?
res = '北⽃阳明贪狼星' in members
print(res)
# '⾏初⼼' 不在列表中吗?
res = '⾏初⼼' not in members
print(res)
if __name__ == '__main__':
巨门
main()
result
/home/coder/anaconda3/envs/py37/bin/python /home/coder/PycharmProjects/DataStructure/demo.py
True
True
Process finished with exit code 0
resource
[⽂档] /3
[规范] /dev/peps/pep-0008
[规范] adthedocs.io/en/latest/google-python-styleguide/python_language_rules
[源码] /downloads/source
[ PEP ] /dev/peps
[平台] wwwblogs
[平台] gitee
Python具有开源、跨平台、解释型、交互式等特性,值得学习。
Python的设计哲学:优雅,明确,简单。提倡⽤⼀种⽅法,最好是只有⼀种⽅法来做⼀件事。代码的书写要遵守规范,这样有助于沟通和理解。
每种语⾔都有独特的思想,初学者需要转变思维、踏实践⾏、坚持积累。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。