学习目标:
①用逗号分隔输出的字符串
②让print不换行
③格式化
- Python日常
内容展示:
①:用逗号分隔输出的字符串
print('aa', 'bb') # aa bb
print('aa', 'bb', sep='中国') # aa中国bb
②:让print不换行
print('hello') # hello
print('world') # world
print('hello', end=' ')
print('world')
# hello world
③:格式化
s = 'road'
x = len(s)
print('The length of %s is %d' %(s, x))
# The length of road is 4
总结:
1.使用sep参数设置字符串之间的间隔,默认是空格。
2.使用end参数设置结尾符号,默认是换行符
3.使用%格式化字符串
- 优快云 Python日常 第10 篇
- 下一篇链接