| Tên phương thức |
Cú pháp |
Ý nghĩa |
Ví dụ |
Kết quả |
| upper |
str.upper() |
Biến đổi thành chuỗi ký tự in hoa |
a.upper() |
a = 'WELCOME LADIES AND GENTLEMEN' |
| lower |
str.lower() |
Biến đổi thành chuỗi ký tự chữ thường |
a.lower() |
a = 'welcome ladies and gentlemen' |
| title |
str.title() |
Biến đổi ký tự đầu tiên của một từ thành ký tự in hoa |
a.title() |
a = 'Welcome Ladies And Gentlemen' |
| split |
str.split() |
Tách 1 chuỗi thành danh dách các chuỗi theo chuỗi phân cách(seprator) |
a.split() |
['welcome', 'ladies', 'and', 'gentlemen'] |
| replace |
str.replace(old, new) |
Thay thế chuỗi con bằng chuỗi mới |
a.replace('ladies', 'women') |
Welcome women and gentlemen |
| strip |
str.strip() |
Xóa các ký tự space, tab, newlines |
a.strip() |
Welcome women and gentlemen |