[course]04 —— String
Learn Python3 The Hard Way
EX6
types_of_people = 10
x = f"There are {types_of_people} types of people."
binary = "binary"
do_not = "don't"
y = f"Those who know {binary} and those who {do_not}."
print(x)
print(y)
print(f"I said: {x}")
print(f"I also said: '{y}'")
hilarious = False
joke_evaluation = "Isn't that joke so funny?! {}"
print(joke_evaluation.format(hilarious)) w = "This is the left side of..."
e = "a string with a right side."
print(w + e)EX7
EX8
EX9

String Literals
1. 四种类型的字符串
2. 换行的几种方式
3. More Escape Sequences
4. An escape sequence produces a single character:
5. repr() 和 print() 方法
6. 多行注释
2. String常量
3. String 操作符
1. String 的 加号 和 乘号
2. in 操作符
3. String indexing and slicing
1. Indexing a single character
2. Negative indexes
3. string 切片
4. 切片的默认参数
5. 切片的步长参数 step
6. 字符串反转
4. Looping over Strings
1. "for" 循环索引字符串
2. "for" loop without indexes
3. "for" loop with split
4. "for" loop with splitlines
5. Example: isPalindrome
**6. Strings are
1. 字符串是不可以修改的,不要修改字符串
2. 要修改字符串应该重新创建一个字符串
7. 字符串的默认方法
1. str() and len()
2. chr() and ord()
3. eval()
8. String方法
1. Character types: isalnum(), isalpha(), isdigit(), islower(), isspace(), isupper()
2. String edits: lower(), upper(), replace(), strip()
3. Substring search: count(), startswith(), endswith(), find(), index()
9. String Formatting
1. format a string with %s
2. format an integer with %d
3. format a float with %f
4. format a float with %.[precision]f
5. format multiple values
6. format right-aligned with %[minWidth]
7. format left-aligned with %-[minWidth]
8. String Formatting with f Strings
10. Basic File IO
Last updated