我的 Python 程序中有一个字符串。我想在第三个之后剥离所有内容.。我试过了strip(),split()但没有得到预期的输出。这该怎么做?
.
strip()
split()
你是这个意思吗?
s = 'aaa.bbb.ccc.xxx.xxx.xxx' stripped = '.'.join(s.split('.')[:3]) print(stripped)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
点击生成二维码
我来说两句