Hướng dẫn Python

TRANG CHỦ Python Giới thiệu Python Python Bắt đầu Cú pháp Python Nhận xét Python Biến Python Các kiểu dữ liệu Python Số Python Đúc Python Chuỗi Python Python Booleans Toán tử Python Danh sách Python Python Tuples Bộ Python Từ điển Python Python Nếu ... Khác Python While Loops Python cho các vòng lặp Các hàm Python Python Lambda Mảng Python Các lớp / đối tượng Python Kế thừa Python Trình lặp lại Python Phạm vi Python Mô-đun Python Ngày trong Python Toán Python JSON Python Python RegEx Python PIP Python Thử ... Ngoại trừ Đầu vào của người dùng Python Định dạng chuỗi Python

Xử lý tập tin

Xử lý tệp Python Tệp đọc Python Viết / tạo tệp trong Python Xóa tệp trong Python

Mô-đun Python

Hướng dẫn NumPy Panda Walkthrough Hướng dẫn Scipy

Python Matplotlib

Giới thiệu Matplotlib Matplotlib Bắt đầu Matplotlib Pyplot Matplotlib Plotting Điểm đánh dấu Matplotlib Dòng Matplotlib Nhãn Matplotlib Matplotlib Grid Matplotlib Subplots Matplotlib Scatter Matplotlib Bars Biểu đồ Matplotlib Biểu đồ bánh Matplotlib

Học máy

Bắt đầu Chế độ trung bình trung bình Độ lệch chuẩn Phân vị Phân phối dữ liệu Phân phối dữ liệu bình thường Lô phân tán Hồi quy tuyến tính Hồi quy đa thức Nhiều hồi quy Tỉ lệ Huấn luyện / Kiểm tra Cây quyết định

Python MySQL

MySQL Bắt đầu MySQL Tạo cơ sở dữ liệu MySQL Tạo bảng Chèn MySQL Lựa chọn MySQL MySQL ở đâu MySQL Đặt hàng bởi MySQL Delete Bảng thả MySQL Cập nhật MySQL Giới hạn MySQL Tham gia MySQL

Python MongoDB

MongoDB Bắt đầu MongoDB Tạo cơ sở dữ liệu MongoDB Tạo Bộ sưu tập Chèn MongoDB MongoDB Tìm Truy vấn MongoDB MongoDB sắp xếp MongoDB Xóa MongoDB Drop Collection Cập nhật MongoDB Giới hạn MongoDB

Tham khảo Python

Tổng quan về Python Các hàm tích hợp trong Python Phương thức chuỗi Python Phương thức danh sách Python Phương thức từ điển Python Phương thức Tuple trong Python Phương thức tập hợp Python Phương thức tệp Python Từ khóa Python Ngoại lệ Python Bảng chú giải thuật ngữ Python

Tham chiếu mô-đun

Mô-đun ngẫu nhiên Mô-đun yêu cầu Mô-đun thống kê Mô-đun Toán học Mô-đun cMath

Python Làm thế nào để

Xóa danh sách trùng lặp Đảo ngược một chuỗi Thêm hai số

Ví dụ Python

Ví dụ Python Trình biên dịch Python Bài tập Python Python Quiz Chứng chỉ Python

Python - Phương thức chuỗi


Phương thức chuỗi

Python có một tập hợp các phương thức tích hợp sẵn mà bạn có thể sử dụng trên các chuỗi.

Lưu ý: Tất cả các phương thức chuỗi đều trả về giá trị mới. Chúng không thay đổi chuỗi gốc.

Method Description
capitalize()Converts the first character to upper case
casefold()Converts string into lower case
center()Returns a centered string
count()Returns the number of times a specified value occurs in a string
encode()Returns an encoded version of the string
endswith()Returns true if the string ends with the specified value
expandtabs()Sets the tab size of the string
find()Searches the string for a specified value and returns the position of where it was found
format()Formats specified values in a string
format_map()Formats specified values in a string
index()Searches the string for a specified value and returns the position of where it was found
isalnum()Returns True if all characters in the string are alphanumeric
isalpha()Returns True if all characters in the string are in the alphabet
isdecimal()Returns True if all characters in the string are decimals
isdigit()Returns True if all characters in the string are digits
isidentifier()Returns True if the string is an identifier
islower()Returns True if all characters in the string are lower case
isnumeric()Returns True if all characters in the string are numeric
isprintable()Returns True if all characters in the string are printable
isspace()Returns True if all characters in the string are whitespaces
istitle() Returns True if the string follows the rules of a title
isupper()Returns True if all characters in the string are upper case
join()Joins the elements of an iterable to the end of the string
ljust()Returns a left justified version of the string
lower()Converts a string into lower case
lstrip()Returns a left trim version of the string
maketrans()Returns a translation table to be used in translations
partition()Returns a tuple where the string is parted into three parts
replace()Returns a string where a specified value is replaced with a specified value
rfind()Searches the string for a specified value and returns the last position of where it was found
rindex()Searches the string for a specified value and returns the last position of where it was found
rjust()Returns a right justified version of the string
rpartition()Returns a tuple where the string is parted into three parts
rsplit()Splits the string at the specified separator, and returns a list
rstrip()Returns a right trim version of the string
split()Splits the string at the specified separator, and returns a list
splitlines()Splits the string at line breaks and returns a list
startswith()Returns true if the string starts with the specified value
strip()Returns a trimmed version of the string
swapcase()Swaps cases, lower case becomes upper case and vice versa
title()Converts the first character of each word to upper case
translate()Returns a translated string
upper()Converts a string into upper case
zfill()Fills the string with a specified number of 0 values at the beginning