Day05 查找find函数用法相关资料的时候,对示例里的运行结果不理解

Open
#4,789 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
documentation

Research direction

No file or test is named in the issue. Start by checking Python's str.find return values and how integers are evaluated in an if condition; done means explaining why the two examples print different results, preferably with a corrected condition or clearer example.

Written by the indexing model from the issue text.

Description

如图看到了如下两段代码:
第一段:
str = "01213456"

if str.find("23"):
print ("YES!")
else:
print ("NO!")
第二段:
str = "01213456"

if str.find("01"):
print("YES!")
else:
print ("NO!")
两段运行的结果分别为1:YES! 2:NO!
不能理解为什么会出现这种不同。

Dominant language
Python
Stars
151
Forks
875
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from xiaolai/selfteaching-python-camp

All issues in xiaolai/selfteaching-python-camp

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.