FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
study-python/chap1/demo5.py at master · xhal/study-python · GitHub
xhal
study-python
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
study-python
/
chap1
/
demo5.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (46 loc) · 1.51 KB
Breadcrumbs
study-python
/
chap1
/
demo5.py
Copy path
File metadata and controls
56 lines (46 loc) · 1.51 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# 版权信息: All rights Reserved, Designed By XHal.cc
# 代码作者: Hal
# 创建时间: 2021/1/21 21:43
# 文件版本: V1.0.0
# 功能描述: 基础数据类型 demo int / float / bool / str
# int - 整数可以表示, 二进制、八进制、十进制(默认)、十六进制
print
(
'二进制'
,
0b11111
)
# 0 零 b 英文字母B
print
(
'八进制'
,
0o117
)
# 0 零 o 英文字母O
print
(
'十进制'
,
118
)
# (默认)
print
(
'十六进制'
,
0x1188
)
# 0 零 x 英文字母X
print
(
'--------------华丽的分隔线-----------------'
)
# float
a
=
3.141592654
print
(
'a'
,
a
)
b
=
2.2
print
(
'b:'
,
b
)
print
(
'a + b:'
,
a
+
b
)
print
(
'b + 1.1:'
,
b
+
1.1
)
# 浮点数,不精确, 如果要精确,引入 decimal 处理
print
(
'--------------华丽的分隔线-----------------'
)
# bool
bo
=
True
print
(
'bo:'
,
bo
)
bo2
=
False
print
(
'bo2:'
,
bo2
)
# bool 可以当作整数计算 True = 1, False = 0
print
(
'bo + 1='
,
bo
+
1
)
print
(
'bo2 + 1='
,
bo2
+
1
)
print
(
'bo + bo2='
,
bo2
+
bo
)
print
(
'--------------华丽的分隔线-----------------'
)
# str
# 单引号 - 只能在一行
s1
=
'人生苦短, hello world'
print
(
s1
,
type
(
s1
))
# 双引号 - 只能在一行
s2
=
"人生苦短, hello world"
print
(
s2
,
type
(
s2
))
# 三引号(单引号) - 可多行输入字符串
s3
=
'''单:这是第一行
,第二行
,第三行'''
print
(
s3
,
type
(
s3
))
# 三引号(双引号) - 可多行输入字符串
s3
=
"""双:这是第一行
,第二行
,第三行"""
print
(
s3
,
type
(
s3
))
Back
|
FazBrowse Home
|
New Git URL