selfteaching / selfteaching/selfteaching-python-camp
Day08 关于如何判断字符串类型的分享
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 151
- Forks
- 875
- PR merge metrics
- No merged PRs in 30d
Description
先了解基本的字符串类型:
整数:int
字符串:str
布尔值: bool
列表:list
元祖:tuple
字典:dict
我这里是用了isinstance函数做判断。
isinstance完整的语法是isinstance(object,classinfo)
object这里输入需要进行判断的对象;
classinfo这里输入类型,比如:int , str;
然后函数会返回True或False。
示例:
a = 1
print(isinstance (a,int))
#输入这个会输出True,因为1属于整数;
print(isinstance (a,str))
#输入这个会输出False,因为1不是字符串;
print(isinstance (a,(str,int,list)))
#输入这个会输出True,因为1属于(str,int,list)三种属性中的int。
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue body discusses Python's isinstance function and basic types, but it names no repository file, test, or documentation entry point. First clarify whether this is meant to become or improve a specific learning document; completion cannot be defined from the current issue alone.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100