找回密码
 中文实名注册
查看: 78|回复: 0

54青年节作业

[复制链接]

697

主题

1085

帖子

2万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
22878
发表于 2024-5-4 09:03:04 | 显示全部楼层 |阅读模式
[Python] 纯文本查看 复制代码
#字符串格式化三种方式
name = 'Alice'
age = 25
height = 1.65
print('我的名字是 %s, 我 %d 岁了, 我的身高是 %.2f 米.' %(name, age, height))

weight = 70.5
print('我的名字是 {}, 我 {}  岁了, 我的体重是 {} .'.format(name, age, weight))

print(f'我的名字是 {name}, 我 {age} 岁了, 我的体重是 {weight} .')

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 中文实名注册

本版积分规则

小黑屋|东台市机器人学会 ( 苏ICP备2021035350号-1;苏ICP备2021035350号-2;苏ICP备2021035350号-3 )

GMT+8, 2024-5-18 18:09 , Processed in 0.043991 second(s), 27 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表