Skip to content

Commit c67e263

Browse files
committed
基础添加占位符相关
1 parent ba933f1 commit c67e263

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

基础.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ for item in range(10):
100100
print(str(random.randint(1, 10)))
101101
```
102102

103+
## 占位符 ##
104+
python中的占位符可以用:%s(替代字符)、%d(替代数字)、%f(替代浮点)来占位,示例如下:
105+
```
106+
info = "姓名:%s \n年龄:%d" % ("老王", 18)
107+
print(info)
108+
# 输出如下:
109+
# 姓名:老王
110+
# 年龄:18
111+
```
103112

104113
## 打印日志 ##
105114
使用关键字“print”输入日志信息,示例如下:

0 commit comments

Comments
 (0)