2020 March 14 python learning Notes - how to tell if a value is not a string None of the role of the ternary operator

+ + Output insist on thinking

1, learning: View provides video (30 minutes) + self-organize notes (2 hours) + video output weekend

2, organize notes by way of questioning.

 How to tell if a value is not a string: use type (variable names)

After the identity of the query is what type of statement can be used to determine if a character stitching, an int is mathematical operations like addition and subtraction

Determining a data type is not str or int the like, may be the identity operator is is not

 >>> type(name) is int

True
>>> type(name) is str
False
>>>
>>> type(name) is not str
True
>>> type(name) is not int
False

 

None: represents the empty

General application scenarios: for example, you store a variable used when no initial value, if the initial value if the variable is not so directly on the error.

Such as playing games, you have to initialize a girlfriend, you need to fill in your name, age, height, weight and other information, which is to allow players to fill in, fill in before, you have to put a good definition of variables, it would have to save a value this value 0,1 to placeholder inappropriate use True, False is also inappropriate, the most appropriate use None

 

 

1, learning: View provides video (30 minutes) + self-organize notes (2 hours) + video output weekend

2, organize notes by way of questioning.

 How to tell if a value is not a string: use type (variable names)

After the identity of the query is what type of statement can be used to determine if a character stitching, an int is mathematical operations like addition and subtraction

Determining a data type is not str or int the like, may be the identity operator is is not

 >>> type(name) is int

True
>>> type(name) is str
False
>>>
>>> type(name) is not str
True
>>> type(name) is not int
False

 

None: represents the empty

General application scenarios: for example, you store a variable used when no initial value, if the initial value if the variable is not so directly on the error.

Such as playing games, you have to initialize a girlfriend, you need to fill in your name, age, height, weight and other information, which is to allow players to fill in, fill in before, you have to put a good definition of variables, it would have to save a value this value 0,1 to placeholder inappropriate use True, False is also inappropriate, the most appropriate use None

 

 

Guess you like

Origin www.cnblogs.com/jianchixuexu/p/12500248.html