### What - immutable / 不可变的 - Strings can be treated as special character [[Array|arrays]], but with dedicated operations and methods. | Operation | Time Complexity | Description | | ----------------- | --------------- | ---------------------------------------- | | **Access** | O(1) | Direct access to character by index | | **Search** | O(n) | Finding character or substring | | **Concatenation** | O(n+m) | Joining two strings | | **Modification** | O(n) | Due to immutability, requires rebuilding | | **Comparison** | O(n) | Lexicographic comparison | ### ASCII [[ASCII]]: the American Standard Code for Information Interchange lowercase - uppercase = 32 ![image.png](https://picture-guan.oss-cn-hangzhou.aliyuncs.com/20230620000444.png) ## Grammer ### process ```python s.replace("a", "b") # 替换 s.lower() / s.upper() # 转大小写 s.strip() / s.lstrip() / s.rstrip() # 去除空格或特定字符 s.split(",") # 拆成列表 ",".join(list_of_str) # 拼成字符串 ``` ### transfer ```python int("123") # 字符串 → 整数 str(456) # 整数 → 字符串 ord('a') # 得到字符的ASCII码 → 97 chr(97) # 得到ASCII码对应的字符 → 'a' ```