CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
jackfrued

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: jackfrued/Python-100-Days
Path: blob/master/Day01-15/code/Day02/strings.py
Views: 729
1
"""
2
字符串常用操作
3
4
Version: 0.1
5
Author: 骆昊
6
Date: 2018-02-27
7
"""
8
9
str1 = 'hello, world!'
10
print('字符串的长度是:', len(str1))
11
print('单词首字母大写: ', str1.title())
12
print('字符串变大写: ', str1.upper())
13
# str1 = str1.upper()
14
print('字符串是不是大写: ', str1.isupper())
15
print('字符串是不是以hello开头: ', str1.startswith('hello'))
16
print('字符串是不是以hello结尾: ', str1.endswith('hello'))
17
print('字符串是不是以感叹号开头: ', str1.startswith('!'))
18
print('字符串是不是一感叹号结尾: ', str1.endswith('!'))
19
str2 = '- \u9a86\u660a'
20
str3 = str1.title() + ' ' + str2.lower()
21
print(str3)
22
23