no message

This commit is contained in:
yinjun.chen1
2026-05-18 17:58:02 +08:00
parent 44a7888fd0
commit 40a027ebd8
5 changed files with 0 additions and 0 deletions
-4
View File
@@ -1,4 +0,0 @@
name = 'chenxuan'
age = '18'
str = f'我的名字:{name},年龄:{age}岁'
print(str)
-8
View File
@@ -1,8 +0,0 @@
# format内的参数起始编号以0开始,即花括号引用的0表示第一个参数,1表示第二个参数
str = '''
窗前明月{0},
疑是地上{1},
举头望明{2},
低头思故{3}
'''
print(str.format('光','霜','月','乡'))
-8
View File
@@ -1,8 +0,0 @@
# format还可以根据关键词引用,这种方式就不需要考虑参数在format内的哪个位置,只根据关键词引用
str = '''
窗前明月{a},
疑是地上{b},
举头望明{c},
低头思故{d}
'''
print(str.format(a='光',b='霜',c='月',d='乡'))
-10
View File
@@ -1,10 +0,0 @@
dict = {
'小明':3.251,
'小李':3.569,
'小白':3.713,
'小花':3.416,
'小张':3.689
}
for name,gpa in dict.items():
print('{0}同学你好,你的成绩为:{1}'.format(name,gpa))
print('*'+name+'*')
-10
View File
@@ -1,10 +0,0 @@
dict = {
'小明':3.251,
'小李':3.569,
'小白':3.713,
'小花':3.416,
'小张':3.689
}
# 使用 冒号+点+数字+f 来指定浮点数在格式化是保留几位小数
for name,gpa in dict.items():
print('{0}同学你好,你的成绩为:{1:.2f}'.format(name,gpa))