首页 > 代码库 > python学习--string
python学习--string
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。