Demo entry 6662850

py

   

Submitted by Mickey on Nov 28, 2017 at 05:41
Language: Python 3. Code size: 249 Bytes.

a = 'www.marsjhao.com.cn'

print (a.split())
['www.marsjhao.com.cn']

print (a.split("."))
['www', 'marsjhao', 'com', 'cn']

print (a.split(".",2))
['www', 'marsjhao', 'com.cn']

print (a.split(".",2)[1])#以"."为分隔符分割2次并取序号为[1]的元素
marsjhao

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).