say = "hello world" print(say[-1]) # d print(say[-5:]) # > world print(say[:5]) # >hello print(say[i:j:k]) # i=开始位置,J= 结束位置 k=跳数 say = "there is 3 monkey in the tree!" # 3 和 tree 不确定是: say = "there is %d monkey in the %s!" print(say % (3,"water"))
ip = 192.168.2.123 ipNew = ip.split('.') # ipNew = ['192', '168', '1', '123'] ".".join(ipNew) #"192.168.1.123" "__".join(ipNew) #192__168__1__123"