python学习--string

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

>>>greeting = 'Hello world!'

>>>greeting[0] = 'J'

TypeError: object does not support item assignment

2The 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

3The relational operators work on strings.

All the uppercase letters come before all the lowercase letters

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