python学习总结——day2

print( )函数打印string、number方式:

##字符串打印方式:

char = 'a'
num = 123

##使用字符串格式化(% 操作符):
print("The character is %c and the number is %d" % (char, num))

##使用str.format()方法:
print("The character is {} and the number is {}".format(char, num))

##使用f-string(Python 3.6+):
print(f"The character is {char} and the number is {num}")

##使用字符串拼接:
print(f"The character is {char} and the number is {num}")

##使用join()方法:
parts = ["The character is ", char, " and the number is ", str(num)]
print("".join(parts))

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值