name = "吹牛"
xing = "擅长 "
xing1 = " 擅长 "
print(xing1, end='', sep='')
print(f'name:{xing},{name}',end=' *** ')
print(f'name:{xing},{name}',end='')
print(xing1.strip(), name, name, name, end='', sep='$$$$')
me = "Houshihao"
print(me.upper())
print(me.lower())
效果:
C:\Anaconda3\envs\pyton\python.exe D:/学习/pyton/零基础入门学python/字符串/删除空白.py
擅长 name:擅长 ,吹牛 *** name:擅长 ,吹牛擅长$$$$吹牛$$$$吹牛$$$$吹牛HOUSHIHAO
houshihao
Process finished with exit code 0
总结:
- f''里面的{}可以替换内容
- str.upper,大写,str.lower(),小写。#对象str.方法upper
- strip()消除两侧的空白
- end=''里面设置结束内容,sep里面设置分隔符,可以是任何字符串*****,之类的都行