Hãy đối mặt với nó. bạn cần lấy thông tin vào và ra khỏi chương trình của mình không chỉ thông qua bàn phím và bảng điều khiển. Trao đổi thông tin qua tệp văn bản là cách phổ biến để chia sẻ thông tin giữa các chương trình. Một trong những định dạng phổ biến nhất để trao đổi dữ liệu là định dạng CSV. Nhưng làm thế nào để bạn sử dụng nó?
Hãy làm rõ một điều. bạn không phải [và bạn sẽ không] xây dựng trình phân tích cú pháp CSV của riêng mình từ đầu. Có một số thư viện hoàn toàn chấp nhận được mà bạn có thể sử dụng. Thư viện Python
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
7 sẽ hoạt động trong hầu hết các trường hợp. Nếu công việc của bạn yêu cầu nhiều dữ liệu hoặc phân tích số, thư viện import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
8 cũng có khả năng phân tích cú pháp CSV, sẽ xử lý phần còn lạiTrong bài viết này, bạn sẽ tìm hiểu cách đọc, xử lý và phân tích cú pháp CSV từ tệp văn bản bằng Python. Bạn sẽ thấy các tệp CSV hoạt động như thế nào, tìm hiểu thư viện
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
7 cực kỳ quan trọng được tích hợp trong Python và xem cách phân tích cú pháp CSV hoạt động bằng thư viện import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
8Vậy hãy bắt đầu
Tải xuống miễn phí. Nhận một chương mẫu từ Python Basics. Giới thiệu thực tế về Python 3 để xem cách bạn có thể đi từ trình độ mới bắt đầu đến trình độ trung cấp trong Python với một chương trình giảng dạy hoàn chỉnh, cập nhật về Python 3. 8
Lấy bài kiểm tra. Kiểm tra kiến thức của bạn với bài kiểm tra tương tác “Đọc và ghi tệp CSV bằng Python” của chúng tôi. Sau khi hoàn thành, bạn sẽ nhận được điểm số để có thể theo dõi quá trình học tập của mình theo thời gian
Lấy bài kiểm tra "
Tệp CSV là gì?
Tệp CSV [tệp Giá trị được phân tách bằng dấu phẩy] là một loại tệp văn bản thuần túy sử dụng cấu trúc cụ thể để sắp xếp dữ liệu dạng bảng. Bởi vì nó là một tệp văn bản thuần túy, nên nó chỉ có thể chứa dữ liệu văn bản thực—nói cách khác, các ký tự ASCII hoặc Unicode có thể in được
Cấu trúc của tệp CSV được đặt theo tên của nó. Thông thường, các tệp CSV sử dụng dấu phẩy để phân tách từng giá trị dữ liệu cụ thể. Đây là cấu trúc đó trông như thế nào
column 1 name,column 2 name, column 3 name
first row data 1,first row data 2,first row data 3
second row data 1,second row data 2,second row data 3
...
Lưu ý cách mỗi phần dữ liệu được phân tách bằng dấu phẩy. Thông thường, dòng đầu tiên xác định từng phần dữ liệu—nói cách khác, tên của cột dữ liệu. Mỗi dòng tiếp theo sau đó là dữ liệu thực tế và chỉ bị giới hạn bởi các ràng buộc về kích thước tệp
Nói chung, ký tự phân cách được gọi là dấu phân cách và dấu phẩy không phải là ký tự duy nhất được sử dụng. Các dấu phân cách phổ biến khác bao gồm các ký tự tab [_______5_______1], dấu hai chấm [
Column names are name, department, birthday month
John Smith works in the Accounting department, and was born in November.
Erica Meyers works in the IT department, and was born in March.
Processed 3 lines.
2] và dấu chấm phẩy [Column names are name, department, birthday month
John Smith works in the Accounting department, and was born in November.
Erica Meyers works in the IT department, and was born in March.
Processed 3 lines.
3]. Phân tích đúng tệp CSV yêu cầu chúng tôi biết dấu phân cách nào đang được sử dụngLoại bỏ các quảng cáoTệp CSV đến từ đâu?
Các tệp CSV thường được tạo bởi các chương trình xử lý lượng lớn dữ liệu. Chúng là một cách thuận tiện để xuất dữ liệu từ bảng tính và cơ sở dữ liệu cũng như nhập hoặc sử dụng dữ liệu đó trong các chương trình khác. Ví dụ: bạn có thể xuất kết quả của chương trình khai thác dữ liệu sang tệp CSV rồi nhập tệp đó vào bảng tính để phân tích dữ liệu, tạo biểu đồ cho bản trình bày hoặc chuẩn bị báo cáo để xuất bản
Các tệp CSV rất dễ làm việc theo chương trình. Bất kỳ ngôn ngữ nào hỗ trợ nhập tệp văn bản và thao tác chuỗi [như Python] đều có thể hoạt động trực tiếp với tệp CSV
Phân tích tệp CSV bằng Thư viện CSV tích hợp của Python
Thư viện
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
7 cung cấp chức năng đọc và ghi vào tệp CSV. Được thiết kế để hoạt động vượt trội với các tệp CSV do Excel tạo, nó có thể dễ dàng điều chỉnh để hoạt động với nhiều định dạng CSV khác nhau. Thư viện import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
7 chứa các đối tượng và mã khác để đọc, viết và xử lý dữ liệu từ và đến các tệp CSVĐọc tệp CSV với import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
7
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
Việc đọc từ tệp CSV được thực hiện bằng cách sử dụng đối tượng
Column names are name, department, birthday month
John Smith works in the Accounting department, and was born in November.
Erica Meyers works in the IT department, and was born in March.
Processed 3 lines.
7. Tệp CSV được mở dưới dạng tệp văn bản với hàm Column names are name, department, birthday month
John Smith works in the Accounting department, and was born in November.
Erica Meyers works in the IT department, and was born in March.
Processed 3 lines.
8 tích hợp sẵn của Python, hàm này trả về một đối tượng tệp. Điều này sau đó được chuyển đến Column names are name, department, birthday month
John Smith works in the Accounting department, and was born in November.
Erica Meyers works in the IT department, and was born in March.
Processed 3 lines.
7, thực hiện công việc nâng vật nặngĐây là tệp
name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
0name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
Đây là mã để đọc nó
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
Điều này dẫn đến đầu ra sau
Column names are name, department, birthday month
John Smith works in the Accounting department, and was born in November.
Erica Meyers works in the IT department, and was born in March.
Processed 3 lines.
Mỗi hàng được trả về bởi
Column names are name, department, birthday month
John Smith works in the Accounting department, and was born in November.
Erica Meyers works in the IT department, and was born in March.
Processed 3 lines.
7 là một danh sách gồm các phần tử name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
2 chứa dữ liệu được tìm thấy bằng cách xóa các dấu phân cách. Hàng đầu tiên được trả về chứa tên cột, được xử lý theo cách đặc biệtĐọc tệp CSV vào từ điển với import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
7
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
Thay vì xử lý danh sách các phần tử
name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
2 riêng lẻ, bạn cũng có thể đọc dữ liệu CSV trực tiếp vào từ điển [về mặt kỹ thuật là Từ điển được sắp xếp]Một lần nữa, tệp đầu vào của chúng tôi,
name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
0 như sauname,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
Đây là mã để đọc nó như một cuốn từ điển lần này
import csv
with open['employee_birthday.txt', mode='r'] as csv_file:
csv_reader = csv.DictReader[csv_file]
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
print[f'\t{row["name"]} works in the {row["department"]} department, and was born in {row["birthday month"]}.']
line_count += 1
print[f'Processed {line_count} lines.']
Điều này dẫn đến đầu ra giống như trước đây
Column names are name, department, birthday month
John Smith works in the Accounting department, and was born in November.
Erica Meyers works in the IT department, and was born in March.
Processed 3 lines.
Các khóa từ điển đến từ đâu? . Nếu bạn không có những thứ này trong tệp CSV của mình, bạn nên chỉ định các khóa của riêng mình bằng cách đặt tham số tùy chọn
name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
6 thành danh sách chứa chúngLoại bỏ các quảng cáoTham số Python CSV Column names are name, department, birthday month
John Smith works in the Accounting department, and was born in November.
Erica Meyers works in the IT department, and was born in March.
Processed 3 lines.
7 tùy chọn
Column names are name, department, birthday month
John Smith works in the Accounting department, and was born in November.
Erica Meyers works in the IT department, and was born in March.
Processed 3 lines.
Đối tượng
Column names are name, department, birthday month
John Smith works in the Accounting department, and was born in November.
Erica Meyers works in the IT department, and was born in March.
Processed 3 lines.
7 có thể xử lý các kiểu tệp CSV khác nhau bằng cách chỉ định , một số kiểu được hiển thị bên dưới
9 chỉ định ký tự được sử dụng để phân tách từng trường. Mặc định là dấu phẩy [name,department,birthday month John Smith,Accounting,November Erica Meyers,IT,March
0]import csv with open['employee_birthday.txt', mode='r'] as csv_file: csv_reader = csv.DictReader[csv_file] line_count = 0 for row in csv_reader: if line_count == 0: print[f'Column names are {", ".join[row]}'] line_count += 1 print[f'\t{row["name"]} works in the {row["department"]} department, and was born in {row["birthday month"]}.'] line_count += 1 print[f'Processed {line_count} lines.']
1 chỉ định ký tự được sử dụng để bao quanh các trường có chứa ký tự phân cách. Mặc định là trích dẫn kép [import csv with open['employee_birthday.txt', mode='r'] as csv_file: csv_reader = csv.DictReader[csv_file] line_count = 0 for row in csv_reader: if line_count == 0: print[f'Column names are {", ".join[row]}'] line_count += 1 print[f'\t{row["name"]} works in the {row["department"]} department, and was born in {row["birthday month"]}.'] line_count += 1 print[f'Processed {line_count} lines.']
2]import csv with open['employee_birthday.txt', mode='r'] as csv_file: csv_reader = csv.DictReader[csv_file] line_count = 0 for row in csv_reader: if line_count == 0: print[f'Column names are {", ".join[row]}'] line_count += 1 print[f'\t{row["name"]} works in the {row["department"]} department, and was born in {row["birthday month"]}.'] line_count += 1 print[f'Processed {line_count} lines.']
3 chỉ định ký tự được sử dụng để thoát ký tự dấu phân cách, trong trường hợp dấu ngoặc kép không được sử dụng. Mặc định là không có ký tự thoátimport csv with open['employee_birthday.txt', mode='r'] as csv_file: csv_reader = csv.DictReader[csv_file] line_count = 0 for row in csv_reader: if line_count == 0: print[f'Column names are {", ".join[row]}'] line_count += 1 print[f'\t{row["name"]} works in the {row["department"]} department, and was born in {row["birthday month"]}.'] line_count += 1 print[f'Processed {line_count} lines.']
Các thông số này xứng đáng được giải thích thêm. Giả sử bạn đang làm việc với tệp
import csv
with open['employee_birthday.txt', mode='r'] as csv_file:
csv_reader = csv.DictReader[csv_file]
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
print[f'\t{row["name"]} works in the {row["department"]} department, and was born in {row["birthday month"]}.']
line_count += 1
print[f'Processed {line_count} lines.']
4 sau đâyname,address,date joined
john smith,1132 Anywhere Lane Hoboken NJ, 07030,Jan 4
erica meyers,1234 Smith Lane Hoboken NJ, 07030,March 2
Tệp CSV này chứa ba trường.
import csv
with open['employee_birthday.txt', mode='r'] as csv_file:
csv_reader = csv.DictReader[csv_file]
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
print[f'\t{row["name"]} works in the {row["department"]} department, and was born in {row["birthday month"]}.']
line_count += 1
print[f'Processed {line_count} lines.']
5, import csv
with open['employee_birthday.txt', mode='r'] as csv_file:
csv_reader = csv.DictReader[csv_file]
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
print[f'\t{row["name"]} works in the {row["department"]} department, and was born in {row["birthday month"]}.']
line_count += 1
print[f'Processed {line_count} lines.']
6 và import csv
with open['employee_birthday.txt', mode='r'] as csv_file:
csv_reader = csv.DictReader[csv_file]
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
print[f'\t{row["name"]} works in the {row["department"]} department, and was born in {row["birthday month"]}.']
line_count += 1
print[f'Processed {line_count} lines.']
7, được phân cách bằng dấu phẩy. Vấn đề là dữ liệu cho trường import csv
with open['employee_birthday.txt', mode='r'] as csv_file:
csv_reader = csv.DictReader[csv_file]
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
print[f'\t{row["name"]} works in the {row["department"]} department, and was born in {row["birthday month"]}.']
line_count += 1
print[f'Processed {line_count} lines.']
6 cũng chứa dấu phẩy để biểu thị mã zipCó ba cách khác nhau để xử lý tình huống này
Sử dụng một dấu phân cách khác
Bằng cách đó, dấu phẩy có thể được sử dụng một cách an toàn trong chính dữ liệu. Bạn sử dụng tham số tùy chọn
9 để chỉ định dấu phân cách mớiname,department,birthday month John Smith,Accounting,November Erica Meyers,IT,March
Gói dữ liệu trong dấu ngoặc kép
Bản chất đặc biệt của dấu phân cách bạn đã chọn bị bỏ qua trong các chuỗi được trích dẫn. Do đó, bạn có thể chỉ định ký tự được sử dụng để trích dẫn với tham số tùy chọn
1. Miễn là ký tự đó cũng không xuất hiện trong dữ liệu, bạn vẫn ổnimport csv with open['employee_birthday.txt', mode='r'] as csv_file: csv_reader = csv.DictReader[csv_file] line_count = 0 for row in csv_reader: if line_count == 0: print[f'Column names are {", ".join[row]}'] line_count += 1 print[f'\t{row["name"]} works in the {row["department"]} department, and was born in {row["birthday month"]}.'] line_count += 1 print[f'Processed {line_count} lines.']
Thoát các ký tự phân cách trong dữ liệu
Các ký tự thoát hoạt động giống như trong các chuỗi định dạng, vô hiệu hóa việc giải thích ký tự được thoát [trong trường hợp này là dấu phân cách]. Nếu một ký tự thoát được sử dụng, nó phải được chỉ định bằng tham số tùy chọn
3import csv with open['employee_birthday.txt', mode='r'] as csv_file: csv_reader = csv.DictReader[csv_file] line_count = 0 for row in csv_reader: if line_count == 0: print[f'Column names are {", ".join[row]}'] line_count += 1 print[f'\t{row["name"]} works in the {row["department"]} department, and was born in {row["birthday month"]}.'] line_count += 1 print[f'Processed {line_count} lines.']
Viết tệp CSV bằng import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
7
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
Bạn cũng có thể ghi vào tệp CSV bằng cách sử dụng đối tượng
Column names are name, department, birthday month
John Smith works in the Accounting department, and was born in November.
Erica Meyers works in the IT department, and was born in March.
Processed 3 lines.
3 và phương thức Column names are name, department, birthday month
John Smith works in the Accounting department, and was born in November.
Erica Meyers works in the IT department, and was born in March.
Processed 3 lines.
4import csv
with open['employee_file.csv', mode='w'] as employee_file:
employee_writer = csv.writer[employee_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL]
employee_writer.writerow[['John Smith', 'Accounting', 'November']]
employee_writer.writerow[['Erica Meyers', 'IT', 'March']]
Tham số tùy chọn
import csv
with open['employee_birthday.txt', mode='r'] as csv_file:
csv_reader = csv.DictReader[csv_file]
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
print[f'\t{row["name"]} works in the {row["department"]} department, and was born in {row["birthday month"]}.']
line_count += 1
print[f'Processed {line_count} lines.']
1 cho biết Column names are name, department, birthday month
John Smith works in the Accounting department, and was born in November.
Erica Meyers works in the IT department, and was born in March.
Processed 3 lines.
3 ký tự nào sẽ được sử dụng để trích dẫn các trường khi viết. Tuy nhiên, việc trích dẫn có được sử dụng hay không được xác định bởi tham số tùy chọn Column names are name, department, birthday month
John Smith works in the Accounting department, and was born in November.
Erica Meyers works in the IT department, and was born in March.
Processed 3 lines.
7- Nếu
7 được đặt thànhColumn names are name, department, birthday month John Smith works in the Accounting department, and was born in November. Erica Meyers works in the IT department, and was born in March. Processed 3 lines.
9, thìColumn names are name, department, birthday month John Smith works in the Accounting department, and was born in November. Erica Meyers works in the IT department, and was born in March. Processed 3 lines.
0 sẽ chỉ trích dẫn các trường nếu chúng chứaname,address,date joined john smith,1132 Anywhere Lane Hoboken NJ, 07030,Jan 4 erica meyers,1234 Smith Lane Hoboken NJ, 07030,March 2
9 hoặcname,department,birthday month John Smith,Accounting,November Erica Meyers,IT,March
1. Đây là trường hợp mặc địnhimport csv with open['employee_birthday.txt', mode='r'] as csv_file: csv_reader = csv.DictReader[csv_file] line_count = 0 for row in csv_reader: if line_count == 0: print[f'Column names are {", ".join[row]}'] line_count += 1 print[f'\t{row["name"]} works in the {row["department"]} department, and was born in {row["birthday month"]}.'] line_count += 1 print[f'Processed {line_count} lines.']
- Nếu
7 được đặt thànhColumn names are name, department, birthday month John Smith works in the Accounting department, and was born in November. Erica Meyers works in the IT department, and was born in March. Processed 3 lines.
4, thìname,address,date joined john smith,1132 Anywhere Lane Hoboken NJ, 07030,Jan 4 erica meyers,1234 Smith Lane Hoboken NJ, 07030,March 2
0 sẽ trích dẫn tất cả các trườngname,address,date joined john smith,1132 Anywhere Lane Hoboken NJ, 07030,Jan 4 erica meyers,1234 Smith Lane Hoboken NJ, 07030,March 2
- Nếu
7 được đặt thànhColumn names are name, department, birthday month John Smith works in the Accounting department, and was born in November. Erica Meyers works in the IT department, and was born in March. Processed 3 lines.
7, thìname,address,date joined john smith,1132 Anywhere Lane Hoboken NJ, 07030,Jan 4 erica meyers,1234 Smith Lane Hoboken NJ, 07030,March 2
0 sẽ trích dẫn tất cả các trường chứa dữ liệu văn bản và chuyển đổi tất cả các trường số thành loại dữ liệuname,address,date joined john smith,1132 Anywhere Lane Hoboken NJ, 07030,Jan 4 erica meyers,1234 Smith Lane Hoboken NJ, 07030,March 2
9name,address,date joined john smith,1132 Anywhere Lane Hoboken NJ, 07030,Jan 4 erica meyers,1234 Smith Lane Hoboken NJ, 07030,March 2
- Nếu
7 được đặt thànhColumn names are name, department, birthday month John Smith works in the Accounting department, and was born in November. Erica Meyers works in the IT department, and was born in March. Processed 3 lines.
1, thìimport csv with open['employee_file.csv', mode='w'] as employee_file: employee_writer = csv.writer[employee_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL] employee_writer.writerow[['John Smith', 'Accounting', 'November']] employee_writer.writerow[['Erica Meyers', 'IT', 'March']]
0 sẽ thoát khỏi dấu phân cách thay vì trích dẫn chúng. Trong trường hợp này, bạn cũng phải cung cấp giá trị cho tham số tùy chọnname,address,date joined john smith,1132 Anywhere Lane Hoboken NJ, 07030,Jan 4 erica meyers,1234 Smith Lane Hoboken NJ, 07030,March 2
3import csv with open['employee_birthday.txt', mode='r'] as csv_file: csv_reader = csv.DictReader[csv_file] line_count = 0 for row in csv_reader: if line_count == 0: print[f'Column names are {", ".join[row]}'] line_count += 1 print[f'\t{row["name"]} works in the {row["department"]} department, and was born in {row["birthday month"]}.'] line_count += 1 print[f'Processed {line_count} lines.']
Đọc lại tệp ở dạng văn bản thuần túy cho thấy tệp được tạo như sau
John Smith,Accounting,November
Erica Meyers,IT,March
Viết tệp CSV từ một từ điển với import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
7
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
Vì bạn có thể đọc dữ liệu của chúng tôi trong từ điển, nên thật công bằng khi bạn cũng có thể viết nó ra từ từ điển
name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
0Không giống như
import csv
with open['employee_file.csv', mode='w'] as employee_file:
employee_writer = csv.writer[employee_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL]
employee_writer.writerow[['John Smith', 'Accounting', 'November']]
employee_writer.writerow[['Erica Meyers', 'IT', 'March']]
5, tham số name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
6 là bắt buộc khi viết từ điển. Điều này có ý nghĩa, khi bạn nghĩ về nó. không có danh sách name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
6, thì import csv
with open['employee_file.csv', mode='w'] as employee_file:
employee_writer = csv.writer[employee_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL]
employee_writer.writerow[['John Smith', 'Accounting', 'November']]
employee_writer.writerow[['Erica Meyers', 'IT', 'March']]
8 không thể biết nên sử dụng khóa nào để truy xuất giá trị từ từ điển của bạn. Nó cũng sử dụng các phím trong name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
6 để viết ra hàng đầu tiên dưới dạng tên cộtĐoạn mã trên tạo ra tệp đầu ra sau
name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
1Loại bỏ các quảng cáoPhân tích tệp CSV với Thư viện import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
8
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
Tất nhiên, thư viện Python CSV không phải là trò chơi duy nhất trong thị trấn. cũng có thể có trong
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
8. Rất khuyến khích nếu bạn có nhiều dữ liệu để phân tíchimport csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
8 là một thư viện Python mã nguồn mở cung cấp các công cụ phân tích dữ liệu hiệu suất cao và cấu trúc dữ liệu dễ sử dụng. import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
8 có sẵn cho tất cả các bản cài đặt Python, nhưng nó là một phần quan trọng của bản phân phối Anaconda và hoạt động cực kỳ hiệu quả trong sổ ghi chép Jupyter để chia sẻ dữ liệu, mã, kết quả phân tích, trực quan hóa và văn bản tường thuậtViệc cài đặt
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
8 và các phụ thuộc của nó trong John Smith,Accounting,November
Erica Meyers,IT,March
5 được thực hiện dễ dàngname,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
2Như đang sử dụng
John Smith,Accounting,November
Erica Meyers,IT,March
6/_______66_______7 cho các bản cài đặt Python khácname,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
3Chúng tôi sẽ không đi sâu vào các chi tiết cụ thể về cách thức hoạt động của
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
8 hoặc cách sử dụng nó. Để biết cách xử lý chuyên sâu về cách sử dụng import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
8 để đọc và phân tích các tập dữ liệu lớn, hãy xem bài viết tuyệt vời của Shantnu Tiwari về cách làm việc với các tệp Excel lớn trong gấu trúcĐọc tệp CSV với import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
8
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
Để thể hiện một số sức mạnh của khả năng CSV của
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
8, tôi đã tạo một tệp phức tạp hơn một chút để đọc, được gọi là name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
02. Nó chứa dữ liệu về nhân viên công tyname,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
4Đọc CSV thành
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
8 name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
04 nhanh chóng và đơn giảnname,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
5Đó là nó. ba dòng mã và chỉ một trong số chúng đang thực hiện công việc thực tế.
name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
05 mở, phân tích và đọc tệp CSV được cung cấp, đồng thời lưu trữ dữ liệu trong DataFrame. In kết quả name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
04 ở đầu ra sauname,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
6Sau đây là một số điểm đáng lưu ý
- Đầu tiên,
8 nhận ra rằng dòng đầu tiên của CSV chứa tên cột và tự động sử dụng chúng. Tôi gọi đây là Thiệnimport csv with open['employee_birthday.txt'] as csv_file: csv_reader = csv.reader[csv_file, delimiter=','] line_count = 0 for row in csv_reader: if line_count == 0: print[f'Column names are {", ".join[row]}'] line_count += 1 else: print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.'] line_count += 1 print[f'Processed {line_count} lines.']
- Tuy nhiên,
8 cũng đang sử dụng các chỉ số số nguyên dựa trên số không trongimport csv with open['employee_birthday.txt'] as csv_file: csv_reader = csv.reader[csv_file, delimiter=','] line_count = 0 for row in csv_reader: if line_count == 0: print[f'Column names are {", ".join[row]}'] line_count += 1 else: print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.'] line_count += 1 print[f'Processed {line_count} lines.']
04. Đó là bởi vì chúng tôi đã không cho nó biết chỉ mục của bạn nên là gìname,department,birthday month John Smith,Accounting,November Erica Meyers,IT,March
Hơn nữa, nếu bạn nhìn vào các loại dữ liệu của các cột của chúng tôi, bạn sẽ thấy
8 đã chuyển đổi chính xác các cộtimport csv with open['employee_birthday.txt'] as csv_file: csv_reader = csv.reader[csv_file, delimiter=','] line_count = 0 for row in csv_reader: if line_count == 0: print[f'Column names are {", ".join[row]}'] line_count += 1 else: print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.'] line_count += 1 print[f'Processed {line_count} lines.']
11 vàname,department,birthday month John Smith,Accounting,November Erica Meyers,IT,March
12 thành số, nhưng cộtname,department,birthday month John Smith,Accounting,November Erica Meyers,IT,March
13 vẫn là mộtname,department,birthday month John Smith,Accounting,November Erica Meyers,IT,March
2. Điều này dễ dàng được xác nhận trong chế độ tương tácname,department,birthday month John Smith,Accounting,November Erica Meyers,IT,March
>>>
7name,department,birthday month John Smith,Accounting,November Erica Meyers,IT,March
Hãy giải quyết từng vấn đề một. Để sử dụng một cột khác làm chỉ mục
name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
04, hãy thêm tham số tùy chọn name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
16name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
8Bây giờ trường
name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
17 là chỉ mục name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
04 của chúng taname,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
9Tiếp theo, hãy sửa kiểu dữ liệu của trường
name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
13. Bạn có thể buộc import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
8 đọc dữ liệu dưới dạng ngày với tham số tùy chọn name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
21, được định nghĩa là danh sách tên cột để coi là ngàyimport csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
0Lưu ý sự khác biệt trong đầu ra
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
1Ngày hiện được định dạng đúng, dễ dàng xác nhận trong chế độ tương tác
>>>
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
2Nếu tệp CSV của bạn không có tên cột trong dòng đầu tiên, bạn có thể sử dụng tham số tùy chọn
name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
22 để cung cấp danh sách tên cột. Bạn cũng có thể sử dụng điều này nếu bạn muốn ghi đè tên cột được cung cấp trong dòng đầu tiên. Trong trường hợp này, bạn cũng phải yêu cầu name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
05 bỏ qua các tên cột hiện có bằng cách sử dụng tham số tùy chọn name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
24import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
3Lưu ý rằng, vì tên cột đã thay đổi nên các cột được chỉ định trong tham số tùy chọn
name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
16 và name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
21 cũng phải được thay đổi. Điều này bây giờ dẫn đến đầu ra sauimport csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
4Loại bỏ các quảng cáoViết tệp CSV bằng import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
8
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
Tất nhiên, nếu bạn không thể lấy lại dữ liệu của mình từ
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
8, thì điều đó cũng chẳng có ích gì cho bạn. Viết một name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
04 vào một tệp CSV cũng dễ dàng như đọc một trong. Hãy ghi dữ liệu với tên cột mới vào tệp CSV mớiimport csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
5Sự khác biệt duy nhất giữa mã này và mã đọc ở trên là cuộc gọi
name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
30 đã được thay thế bằng name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
31, cung cấp tên tệp. Tệp CSV mới trông như thế nàyimport csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
6Phần kết luận
Nếu bạn hiểu những kiến thức cơ bản về đọc tệp CSV, thì bạn sẽ không bao giờ bị lúng túng khi cần xử lý việc nhập dữ liệu. Hầu hết các tác vụ đọc, xử lý và viết CSV có thể được xử lý dễ dàng bằng thư viện Python
import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
7 cơ bản. Nếu bạn có nhiều dữ liệu cần đọc và xử lý, thư viện import csv
with open['employee_birthday.txt'] as csv_file:
csv_reader = csv.reader[csv_file, delimiter=',']
line_count = 0
for row in csv_reader:
if line_count == 0:
print[f'Column names are {", ".join[row]}']
line_count += 1
else:
print[f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.']
line_count += 1
print[f'Processed {line_count} lines.']
8 cũng cung cấp khả năng xử lý CSV nhanh chóng và dễ dàngLấy bài kiểm tra. Kiểm tra kiến thức của bạn với bài kiểm tra tương tác “Đọc và ghi tệp CSV bằng Python” của chúng tôi. Sau khi hoàn thành, bạn sẽ nhận được điểm số để có thể theo dõi quá trình học tập của mình theo thời gian
Lấy bài kiểm tra "
Có cách nào khác để phân tích tệp văn bản không? . Các thư viện như ANTLR, PLY và PlyPlus đều có thể xử lý phân tích cú pháp hạng nặng và nếu thao tác
name,department,birthday month
John Smith,Accounting,November
Erica Meyers,IT,March
2 đơn giản không hoạt động, thì luôn có các biểu thức chính quyNhưng đó là những chủ đề cho các bài viết khác…
Tải xuống miễn phí. Nhận một chương mẫu từ Python Basics. Giới thiệu thực tế về Python 3 để xem cách bạn có thể đi từ trình độ mới bắt đầu đến trình độ trung cấp trong Python với một chương trình giảng dạy hoàn chỉnh, cập nhật về Python 3. 8
Đánh dấu là đã hoàn thành
Xem ngay Hướng dẫn này có một khóa học video liên quan do nhóm Real Python tạo. Xem nó cùng với hướng dẫn bằng văn bản để hiểu sâu hơn. Đọc và ghi tệp CSV
🐍 Thủ thuật Python 💌
Nhận một Thủ thuật Python ngắn và hấp dẫn được gửi đến hộp thư đến của bạn vài ngày một lần. Không có thư rác bao giờ. Hủy đăng ký bất cứ lúc nào. Được quản lý bởi nhóm Real Python
Gửi cho tôi thủ thuật Python »
Giới thiệu về Jon Fincher
Jon đã dạy Python và Java tại hai trường trung học ở Bang Washington. Trước đây, ông là Giám đốc Chương trình tại Microsoft
» Thông tin thêm về JonMỗi hướng dẫn tại Real Python được tạo bởi một nhóm các nhà phát triển để nó đáp ứng các tiêu chuẩn chất lượng cao của chúng tôi. Các thành viên trong nhóm đã làm việc trong hướng dẫn này là
Aldren
Geir Arne
Joanna
Jason
Bậc thầy Kỹ năng Python trong thế giới thực Với quyền truy cập không giới hạn vào Python thực
Tham gia với chúng tôi và có quyền truy cập vào hàng nghìn hướng dẫn, khóa học video thực hành và cộng đồng các Pythonistas chuyên gia
Nâng cao kỹ năng Python của bạn »
Chuyên gia Kỹ năng Python trong thế giới thực
Với quyền truy cập không giới hạn vào Python thực
Tham gia với chúng tôi và có quyền truy cập vào hàng ngàn hướng dẫn, khóa học video thực hành và cộng đồng Pythonistas chuyên gia
Nâng cao kỹ năng Python của bạn »
Bạn nghĩ sao?
Đánh giá bài viết này
Tweet Chia sẻ Chia sẻ EmailBài học số 1 hoặc điều yêu thích mà bạn đã học được là gì?
Mẹo bình luận. Những nhận xét hữu ích nhất là những nhận xét được viết với mục đích học hỏi hoặc giúp đỡ các sinh viên khác. và nhận câu trả lời cho các câu hỏi phổ biến trong cổng thông tin hỗ trợ của chúng tôi