selfteaching / selfteaching/selfteaching-python-camp

Day08 关于如何判断字符串类型的分享

Open
#1,046 0 comments 0 reactions 0 assignees View on GitHub

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

  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.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.