Dưới đây là mã chức năng [tạo tệp với thành công]
sys.stdout = open['filename1.xml', 'w']
Bây giờ tôi đang cố gắng đặt tên cho tệp với ngày/giờ hiện tại [tôi không phải là chuyên gia về Python]
filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
Tôi muốn viết ra một tên tệp với ngày và thời gian chính xác, đó là tệp XML, mà chương trình đã tạo, tôi chỉ cần đặt tên cho tệp. Mã trên không hoạt động.
Lỗi đã trả về:
File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
Cải thiện bài viết
Lưu bài viết
Điều kiện tiên quyết: Mô -đun DateTime DateTime module
Trong bài viết này, chúng ta sẽ xem cách tạo tên tệp có ngày hoặc thời gian bằng Python. & NBSP;
Đối với điều này, chúng tôi sẽ sử dụng mô -đun DateTime. Đầu tiên, nhập mô -đun và sau đó nhận thời gian hiện tại với đối tượng DateTime.now []. Bây giờ hãy chuyển đổi nó thành một chuỗi và sau đó tạo một tệp với đối tượng tệp giống như một tệp thông thường được tạo bằng cách sử dụng các khái niệm xử lý tệp trong Python.
Ví dụ 1: Tạo tệp văn bản chứa ngày/giờ & nbsp;Creating text file containing date/time
Python3
from
datetime
filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
0 filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
1filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
2filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
3 filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
4filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
5filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
6filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
7filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
8filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
9filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
3 File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
1 File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
2 File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
3filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
3 File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
5 File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
6 File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
7 File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
8 filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
3 import datetime
import os
# Path to the file
path = r"E:\demos\files_demos\sample.txt"
# file modification timestamp of a file
m_time = os.path.getmtime[path]
# convert timestamp into DateTime object
dt_m = datetime.datetime.fromtimestamp[m_time]
print['Modified on:', dt_m]
# file creation timestamp in float
c_time = os.path.getctime[path]
# convert creation timestamp into DateTime object
dt_c = datetime.datetime.fromtimestamp[c_time]
print['Created on:', dt_c]
0import datetime
import os
# Path to the file
path = r"E:\demos\files_demos\sample.txt"
# file modification timestamp of a file
m_time = os.path.getmtime[path]
# convert timestamp into DateTime object
dt_m = datetime.datetime.fromtimestamp[m_time]
print['Modified on:', dt_m]
# file creation timestamp in float
c_time = os.path.getctime[path]
# convert creation timestamp into DateTime object
dt_c = datetime.datetime.fromtimestamp[c_time]
print['Created on:', dt_c]
1import datetime
import os
# Path to the file
path = r"E:\demos\files_demos\sample.txt"
# file modification timestamp of a file
m_time = os.path.getmtime[path]
# convert timestamp into DateTime object
dt_m = datetime.datetime.fromtimestamp[m_time]
print['Modified on:', dt_m]
# file creation timestamp in float
c_time = os.path.getctime[path]
# convert creation timestamp into DateTime object
dt_c = datetime.datetime.fromtimestamp[c_time]
print['Created on:', dt_c]
2import datetime
import os
# Path to the file
path = r"E:\demos\files_demos\sample.txt"
# file modification timestamp of a file
m_time = os.path.getmtime[path]
# convert timestamp into DateTime object
dt_m = datetime.datetime.fromtimestamp[m_time]
print['Modified on:', dt_m]
# file creation timestamp in float
c_time = os.path.getctime[path]
# convert creation timestamp into DateTime object
dt_c = datetime.datetime.fromtimestamp[c_time]
print['Created on:', dt_c]
3filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
5filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
6import datetime
import os
# Path to the file
path = r"E:\demos\files_demos\sample.txt"
# file modification timestamp of a file
m_time = os.path.getmtime[path]
# convert timestamp into DateTime object
dt_m = datetime.datetime.fromtimestamp[m_time]
print['Modified on:', dt_m]
# file creation timestamp in float
c_time = os.path.getctime[path]
# convert creation timestamp into DateTime object
dt_c = datetime.datetime.fromtimestamp[c_time]
print['Created on:', dt_c]
6import datetime
import os
# Path to the file
path = r"E:\demos\files_demos\sample.txt"
# file modification timestamp of a file
m_time = os.path.getmtime[path]
# convert timestamp into DateTime object
dt_m = datetime.datetime.fromtimestamp[m_time]
print['Modified on:', dt_m]
# file creation timestamp in float
c_time = os.path.getctime[path]
# convert creation timestamp into DateTime object
dt_c = datetime.datetime.fromtimestamp[c_time]
print['Created on:', dt_c]
7 File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
8import datetime
import os
# Path to the file
path = r"E:\demos\files_demos\sample.txt"
# file modification timestamp of a file
m_time = os.path.getmtime[path]
# convert timestamp into DateTime object
dt_m = datetime.datetime.fromtimestamp[m_time]
print['Modified on:', dt_m]
# file creation timestamp in float
c_time = os.path.getctime[path]
# convert creation timestamp into DateTime object
dt_c = datetime.datetime.fromtimestamp[c_time]
print['Created on:', dt_c]
9 File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
8Modified on: 2021-07-02 16:47:50.791990 Created on: 2021-06-30 17:21:57.9147741
Output:
Ngày & giờ hiện tại: 2021-08-19 13: 17: 48.408908
Tệp được tạo: & nbsp; 2021-08-19 13: 17: 48.408908.txt
Bất kỳ loại tệp nào cũng có thể được tạo theo cách này nếu tiện ích mở rộng được yêu cầu được cung cấp chính xác.
Ví dụ 2: & nbsp; tạo tệp CSV chứa ngày/giờ & nbsp;Creating CSV file containing date/time
Python3
from
datetime
filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
0 filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
1filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
2filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
3 filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
4filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
5filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
6filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
7filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
8filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
9filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
3 File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
1 File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
2 File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
3filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
3 File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
5 File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
6 File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
7 File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
8 filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
3 import datetime
import os
# Path to the file
path = r"E:\demos\files_demos\sample.txt"
# file modification timestamp of a file
m_time = os.path.getmtime[path]
# convert timestamp into DateTime object
dt_m = datetime.datetime.fromtimestamp[m_time]
print['Modified on:', dt_m]
# file creation timestamp in float
c_time = os.path.getctime[path]
# convert creation timestamp into DateTime object
dt_c = datetime.datetime.fromtimestamp[c_time]
print['Created on:', dt_c]
0import datetime
import os
# Path to the file
path = r"E:\demos\files_demos\sample.txt"
# file modification timestamp of a file
m_time = os.path.getmtime[path]
# convert timestamp into DateTime object
dt_m = datetime.datetime.fromtimestamp[m_time]
print['Modified on:', dt_m]
# file creation timestamp in float
c_time = os.path.getctime[path]
# convert creation timestamp into DateTime object
dt_c = datetime.datetime.fromtimestamp[c_time]
print['Created on:', dt_c]
1import datetime
import os
# Path to the file
path = r"E:\demos\files_demos\sample.txt"
# file modification timestamp of a file
m_time = os.path.getmtime[path]
# convert timestamp into DateTime object
dt_m = datetime.datetime.fromtimestamp[m_time]
print['Modified on:', dt_m]
# file creation timestamp in float
c_time = os.path.getctime[path]
# convert creation timestamp into DateTime object
dt_c = datetime.datetime.fromtimestamp[c_time]
print['Created on:', dt_c]
2import datetime
import os
# Path to the file
path = r"E:\demos\files_demos\sample.txt"
# file modification timestamp of a file
m_time = os.path.getmtime[path]
# convert timestamp into DateTime object
dt_m = datetime.datetime.fromtimestamp[m_time]
print['Modified on:', dt_m]
# file creation timestamp in float
c_time = os.path.getctime[path]
# convert creation timestamp into DateTime object
dt_c = datetime.datetime.fromtimestamp[c_time]
print['Created on:', dt_c]
3filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
5filename1 = datetime.now[].strftime["%Y%m%d-%H%M%S"]
sys.stdout = open[filename1 + '.xml', 'w']
6import datetime
import os
# Path to the file
path = r"E:\demos\files_demos\sample.txt"
# file modification timestamp of a file
m_time = os.path.getmtime[path]
# convert timestamp into DateTime object
dt_m = datetime.datetime.fromtimestamp[m_time]
print['Modified on:', dt_m]
# file creation timestamp in float
c_time = os.path.getctime[path]
# convert creation timestamp into DateTime object
dt_c = datetime.datetime.fromtimestamp[c_time]
print['Created on:', dt_c]
6import datetime
import os
# Path to the file
path = r"E:\demos\files_demos\sample.txt"
# file modification timestamp of a file
m_time = os.path.getmtime[path]
# convert timestamp into DateTime object
dt_m = datetime.datetime.fromtimestamp[m_time]
print['Modified on:', dt_m]
# file creation timestamp in float
c_time = os.path.getctime[path]
# convert creation timestamp into DateTime object
dt_c = datetime.datetime.fromtimestamp[c_time]
print['Created on:', dt_c]
7 File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
8import datetime
import os
# Path to the file
path = r"E:\demos\files_demos\sample.txt"
# file modification timestamp of a file
m_time = os.path.getmtime[path]
# convert timestamp into DateTime object
dt_m = datetime.datetime.fromtimestamp[m_time]
print['Modified on:', dt_m]
# file creation timestamp in float
c_time = os.path.getctime[path]
# convert creation timestamp into DateTime object
dt_c = datetime.datetime.fromtimestamp[c_time]
print['Created on:', dt_c]
9 File "./fix.py", line 226, in
filenames = datetime.now[].strftime["%Y%m%d-%H%M%S"]
AttributeError: 'module' object has no attribute 'now'
8Modified on: 2021-07-02 16:47:50.791990 Created on: 2021-06-30 17:21:57.9147741
Output:
Ngày & giờ hiện tại: 2021-08-19 13: 17: 48.408908
Tệp được tạo: & nbsp; 2021-08-19 13: 17: 48.408908.txt
Có nhiều cách để tạo ra và sửa đổi dữ liệu trong Python. Chúng tôi sẽ sử dụng các phương thức sau của mô -đun HĐH và PATHLIB để có được thời gian sửa đổi và tạo tệp trong Python.following methods of an OS and pathlib module to get file modification and creation time in Python.
Mô -đun OS.Path::
2021-12-24 13:35:41.257598 2021-12-24 13:35:41.257598
6: Cách đa nền tảng để có được thời gian sửa đổi tệp trong Python. Nó trả về dấu thời gian UNIX của khi tệp được sửa đổi lần cuối.2021-12-24 13:35:41.257598 2021-12-24 13:35:41.257598
7: Để có thời gian tạo tệp nhưng chỉ trên Windows.2021-12-24 13:35:41.257598 2021-12-24 13:35:41.257598
8: Để có thời gian tạo tệp trên MAC và một số hệ thống dựa trên Unix.
Mô -đun Pathlib::
2021-12-24 13:35:41.257598 2021-12-24 13:35:41.257598
9: Cách đa nền tảng tốt nhất để có được thời gian sửa đổi tệp trong Python.from
0: Để có thời gian tạo tệp nhưng chỉ trên Windows và siêu dữ liệu gần đây thay đổi thời gian
Cách nhận được thời gian sửa đổi và tạo tệp trong Python
Các bước dưới đây cho thấy cách sử dụng mô -đun OS.Path và mô -đun DateTime để có thời gian tạo và sửa đổi của một tệp trong Python.
- Nhập mô -đun OS.Path và mô -đun DateTime
Mô -đun
from
1 thực hiện một số hàm có giá trị trên các tên đường dẫn. Nó rất hữu ích để có được siêu dữ liệu của một tập tin.Mô-đun DateTime được sử dụng để chuyển đổi thời gian tạo và sửa đổi được trả về bởi mô-đun
from
1 sang định dạng có thể đọc được của con người như ngày, năm, tháng, giờ, phút và giây [DD-MM-YYYY HH: MM: SS]. - Sử dụng hàm getMtime [] để có thời gian sửa đổi
Hàm
from
3 trả về thời gian sửa đổi trong dấu thời gian số trong float. Vượt qua đường dẫn tệp, như một đường dẫn tuyệt đối hoặc tương đối đến một tệp. - Bao bọc thời gian tạo và sửa đổi trong một đối tượng DateTime.
DateTime được trả về bởi
datetime
8 và Sdatetime
9 ở định dạng dấu thời gian số. Sử dụng phương phápfrom
5 để định dạng nó theo định dạng có thể đọc được của con người [DD-MM-YYYY HH: MM: SS] - Thí dụ
Bài tập và câu đố Python
Các bài tập mã hóa miễn phí và các câu đố bao gồm các vấn đề cơ bản của Python, cấu trúc dữ liệu, phân tích dữ liệu, v.v.on Unix, it will not work. Instead, it will return the timestamp of the last time when the file’s attributes or content were changed [most recent metadata change on Unix].
Hơn 15 bài tập và câu đố dành riêng cho chủ đề
import datetime
import os
# Path to the file
path = r"E:\demos\files_demos\sample.txt"
# file modification timestamp of a file
m_time = os.path.getmtime[path]
# convert timestamp into DateTime object
dt_m = datetime.datetime.fromtimestamp[m_time]
print['Modified on:', dt_m]
# file creation timestamp in float
c_time = os.path.getctime[path]
# convert creation timestamp into DateTime object
dt_c = datetime.datetime.fromtimestamp[c_time]
print['Created on:', dt_c]
Output::
Modified on: 2021-07-02 16:47:50.791990 Created on: 2021-06-30 17:21:57.914774
Mỗi bài tập chứa 10 câu hỏi: If you want to represent datetime in different formats see Python Datetime formatting.
Mỗi bài kiểm tra chứa 12-15 mcq
- Có nhiều cách để tạo ra và sửa đổi dữ liệu trong Python. Chúng tôi sẽ sử dụng các phương thức sau của mô -đun HĐH và PATHLIB để có được thời gian sửa đổi và tạo tệp trong Python., as well as some Unix based systems, you can use the
from
7 attribute of afrom
8 or [ fsta[]/lstat[]] to function get the file creation time. - Nhưng, thuộc tính
from
9 củadatetime
0 không được đảm bảo có sẵn trên tất cả các hệ thống như Linux. - Chúng ta cần chuyển đổi tmestamp số nguyên được trả về bởi
from
9 thành đối tượng DateTime bằng cách sử dụngdatetime
2.
Example::
import os
import datetime
# Path to the file
path = r"/Users/myfiles/sample.txt"
# get file creation time on mac
stat = os.stat[path]
c_timestamp = stat.st_birthtime
c_time = datetime.datetime.fromtimestamp[c_timestamp]
print[c_time]
Mô -đun Pathlib để có được dữ liệu tạo và sửa đổi của tệp
Từ Python 3.4 trở đi, chúng ta có thể sử dụng mô -đun Pathlib, cung cấp một trình bao bọc cho hầu hết các chức năng HĐH. Mô -đun này cung cấp các lớp đại diện cho các đường dẫn hệ thống tập tin với ngữ nghĩa phù hợp cho các hệ điều hành khác nhau.
Hãy cùng xem cách sử dụng mô -đun Pathlib và mô -đun DateTime để có được dữ liệu tạo và sửa đổi của một tệp trong Python.
Nhập mô -đun Pathlib và Mô -đun DateTime::
- Mô -đun Pathlib cung cấp các lớp và phương thức để xử lý các đường dẫn hệ thống tập tin và nhận dữ liệu liên quan đến các tệp cho các hệ điều hành khác nhau.
- Mô-đun DateTime được sử dụng để chuyển đổi thời gian tạo và sửa đổi được trả về bởi mô-đun Pathlib thành định dạng có thể đọc được của con người [DD-MM-YYYY HH: MM: SS].
Sử dụng datetime
3 để xây dựng đường dẫn tệp
Đường dẫn tuyệt đối hoặc tương đối của một tập tin. Sử dụng lớp ____94 để tạo một đường dẫn cụ thể [vị trí của tệp] của hương vị đường dẫn hệ thống. Nó sẽ trả về đối tượng Đường dẫn tệp.
Đó là một triển khai đa nền tảng. Ví dụ: nếu bạn thực hiện điều này trên Windows, bạn sẽ nhận được phiên bản của lớp ‘pathlib.windowspath.
Sử dụng phương thức stat [] của đối tượng pathlib
Để có được thời gian tạo và sửa đổi của một tệp, hãy sử dụng phương thức datetime
5] của đối tượng pathlib. Phương thức này trả về siêu dữ liệu và các thông tin khác nhau liên quan đến một tệp, chẳng hạn như kích thước tệp, sáng tạo và thời gian sửa đổi.
- Sử dụng
datetime
6 để có thời gian sửa đổi nội dung cuối cùng tính bằng giây datetime
7 [phụ thuộc vào nền tảng]:- Thời gian thay đổi siêu dữ liệu gần đây nhất trên Unix,
- Thời gian tạo trên Windows được thể hiện bằng giây.
Bao bọc thời gian tạo và sửa đổi trong một đối tượng DateTime..
DateTime được trả về bởi datetime
8 và Sdatetime
9 ở định dạng dấu thời gian số. Sử dụng phương pháp from
5 để định dạng nó theo định dạng có thể đọc được của con người [DD-MM-YYYY HH: MM: SS]
Thí dụ
import datetime
import pathlib
# create a file path
f_name = pathlib.Path[r'E:\demos\oop_demos\test.txt']
# get modification time
m_timestamp = f_name.stat[].st_mtime
# convert ti to dd-mm-yyyy hh:mm:ss
m_time = datetime.datetime.fromtimestamp[m_timestamp]
print[m_time]
# get creation time on windows
c_timestamp = f_name.stat[].st_ctime
c_time = datetime.datetime.fromtimestamp[c_timestamp]
print[c_time]
Output::
2021-12-24 13:35:41.257598 2021-12-24 13:35:41.257598
Bài tập và câu đố Python
Các bài tập mã hóa miễn phí và các câu đố bao gồm các vấn đề cơ bản của Python, cấu trúc dữ liệu, phân tích dữ liệu, v.v.
- Hơn 15 bài tập và câu đố dành riêng cho chủ đềTopic-specific Exercises and Quizzes
- Mỗi bài tập chứa 10 câu hỏi
- Mỗi bài kiểm tra chứa 12-15 mcq