其他分享
首页 > 其他分享> > print 高级用法

print 高级用法

作者:互联网

my_name='zhangsan'
print(f"Let's talk {my_name},Don't paly basketball in the room")

#等价于下面方式

print("Let's talk {},Don't paly basketball in the room".format(my_name))

#打印结果如下:
'''
Let's talk zhangsan,Don't paly basketball in the room
Let's talk zhangsan,Don't paly basketball in the room
'''

#当然想打印出这个相同的结果还有好多种方法

print("Let's talk %s,Don't paly basketball in the room"%my_name)

print("Let's talk "+my_name+",Don't paly basketball in the room")

'''
Let's talk zhangsan,Don't paly basketball in the room
Let's talk zhangsan,Don't paly basketball in the room
'''

 

标签:paly,basketball,Don,room,高级,用法,Let,print,talk
来源: https://www.cnblogs.com/liangliangzz/p/11712124.html