码迷,mamicode.com
首页 > 编程语言 > 详细

python学习--string

时间:2014-08-11 17:06:42      阅读:256      评论:0      收藏:0      [点我收藏+]

标签:io   strong   for   ar   cti   amp   python   type   

1\string are immutable, which means you can‘t change an existing string.

>>>greeting = ‘Hello world!‘

>>>greeting[0] = ‘J‘

TypeError: object does not support item assignment

2\The world in is a boolean operator that takes two strings and returns True if the first appears as a substring in the second. For example, the following function prints all the letters from word1 that also appear in word2:

>>>def in_both(word1, word2):

>>>      for letter in word1:

>>>            if letter in word2:

>>>                print letter

3\The relational operators work on strings.

All the uppercase letters come before all the lowercase letters

python学习--string,布布扣,bubuko.com

python学习--string

标签:io   strong   for   ar   cti   amp   python   type   

原文地址:http://www.cnblogs.com/siriuswang/p/3904916.html

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