当前位置:网站首页>4.7 type() function query data type
4.7 type() function query data type
2022-06-30 15:16:00 【Andy Python learning notes】
4.7 type( ) Function to query the data type
type( ) effect : Query data type .
grammar :type(' The content of the query ')
frequently-used 3 Type of data :
1、Python The first data type : character string (str).
2、Python The second data type : Integers (int).
3、Python The third data type : Floating point numbers (float).
# Set a string variable
name = ' Andy '
# Query the data type of the variable .
type(name)
【 Terminal output 】
str
Output after running code str
Explanatory variable name The data type of is string .
# Set an integer variable
phone_number = 18087558755
# Query the data type of the variable .
type(phone_number)
【 Terminal output 】
int
Output after running code int
Explanatory variable phone_number The data type of is integer .
# Set a floating point variable
number = 88.88
# use print Function to query the data type of a variable .
print(type(number))
【 Terminal output 】
<class ‘float’>
Output after running code float Explanatory variable number The data type of is a floating point number .
stay .ipynb In file , Output content can be used print( ) function , You can also call variable output directly ( for example :type(phone_number)).
stay .py In file , Output content can only be used print( ) function .
class In this case, it refers to the data type .
# Define three variables
name = ' Zhang San '
number_1 = 8888
number_2 = 0.66
# print( ) Function view data type
print(type(name))
print(type(number_1))
print(type(number_2))
【 Terminal output 】
<class ‘str’>
<class ‘int’>
<class ‘float’>
边栏推荐
- CCF drawing (full mark code + problem solving ideas + skill summary) February 2, 2014
- Expressions in if statements
- 1151 LCA in a binary tree (30 points)
- CCF string matching (Full Score code + problem solving ideas + skill summary) March 3, 2014
- IO interview questions
- L - Jungle roads (minimum spanning tree)
- 1135: paired base chain
- Technology sharing | anyrtc service single port design
- The short video and live broadcast incubation training camp with goods opens nationwide enrollment!
- Xiao Sha's pain (thinking problem)
猜你喜欢
CCF window (Full Score code + problem solving idea) March 2, 2014
Basic literacy - four common software architectures
Kubernetes: a comprehensive analysis of container choreography
Help you accumulate audio and video knowledge, Agora developer's roaming guide officially set sail
Solve the problem that codeblocks20.03 on win11 cannot run for the first time
[ten thousand words long article] thoroughly understand load balancing
Npumcm selection question 3 and acmc2020a
Complement (Niuke)
Preliminary study on AI noise reduction evaluation system of sound network
Shift operator (detailed)
随机推荐
Is pioneer futures safe? What are the procedures for opening futures accounts? How to reduce the futures commission?
Matlab function for limit, definite integral, first-order derivative, second-order derivative (classic examples)
1019 general palindromic number (20 points)
[matlab] 2D drawing summary
Matlab two-dimensional array example (extract data)
1133: output family and friends string
1018 public bike Management (30 points)
Average and maximum values of MATLAB matrix
立式加工中心的数控加工对刀具使用基本要求
The short video and live broadcast incubation training camp with goods opens nationwide enrollment!
1150 traveling salesman problem (25 points)
Super comprehensive redis distributed high availability solution: sentry mechanism
1035 password (20 points)
CCF sequence segmentation (Full Score code + problem solving idea) 201509 -1
HD mechanical principle · classic dynamic drawing of mechanical design
Expressions in if statements
1149 dangerous goods packaging (25 points)
Infrastructure is code. What are you talking about?
CCF window (Full Score code + problem solving idea) March 2, 2014
Don't fight for big companies