码迷,mamicode.com
首页 > 其他好文 > 详细

字符串相关

时间:2017-10-18 21:37:53      阅读:108      评论:0      收藏:0      [点我收藏+]

标签:this   list   nta   limit   oop   ring   contain   字符串   china   

#!/usr/bin/python
# Filename: str_methods.py

name = ‘Swaroop‘ # This is a string object

if name.startswith(‘Swa‘):
print ‘Yes, the string starts with "Swa"‘

if ‘a‘ in name:
print ‘Yes, it contains the string "a"‘

if name.find(‘war‘) != -1:
print ‘Yes, it contains the string "war"‘

delimiter = ‘_*_‘
mylist = [‘Brazil‘, ‘Russia‘, ‘India‘, ‘China‘]
print delimiter.join(mylist)

字符串相关

标签:this   list   nta   limit   oop   ring   contain   字符串   china   

原文地址:http://www.cnblogs.com/nku-wangfeng/p/7688963.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!