- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.py
More file actions
Latest commit
26 lines (21 loc) · 796 Bytes
/
Copy pathstrings.py
File metadata and controls
26 lines (21 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
a='a'
a="a"
a="""this
is
a
multi-line
string"""
a=''' you can also write me like this'''
# white space between string literals is ignored . for example:
print("hell""o"=="hello")
# all strings in python 3 are unicode. in python 2 you should have written unicode strings like u'some unicode'
# a lot of useful string methods!
test_string='This is a TEST string!'
print(test_string.capitalize())
print(test_string.lower())
print(test_string.endswith('h')) # there is also startswith
print(test_string.count('i'))
print(test_string.center(50))
print(test_string.casefold()) # casefold is used for comparison.
print('splitting a string with spaces:\n\t{}'.format('this is a sentence').split(' '))
# a lot of other builtin string methods, including title, swapcase, upper and ...