字符串格式化

来源:互联网 发布:mac个人收藏添加 编辑:程序博客网 时间:2024/06/06 12:52

字符串格式化

使用字符串格式化操作符即%实现

在%左侧放置一个字符串(格式化字符串),而右侧放置希望格式化的值。

 

format='hello,%s.%senough for ya'

values=('wrold','hot')

print format%values

 

 

defhello_1(greeting,name):

    print '%s,%s'%(greeting,name)

hello_1('hello','world')


0 0
原创粉丝点击