cuốn sách gpt4 ai đã làm

Ghi chú sắp xếp thư mục Python

In lại Tác giả: Người biết Thời gian cập nhật: 2024-03-13 09:44:03 31 4
mua khóa gpt4 Nike

Phân loại tự nhiên Natsort:

cài đặt pip natsort

if __name__ == '__main__': from natsort import natsorted x = ['41', '2', '11', '33'] y=natsorted(x) print(x) print(y)

kết quả:

['41', '2', '11', '33']
['2', '11', '33', '41']

Sắp xếp thời gian thư mục Python

def new_report(test_report):lists =glob.glob(test_report+'/*.png') # Liệt kê tất cả các file và thư mục trong thư mục và lưu chúng vào list print(lists) List.sort(key=lambda filen: os.path .getmtime( filen)) # Sắp xếp theo thời gian file_new = danh sách # Lấy file mới nhất và lưu vào file_new return file_new if __name__ == '__main__': file_new = new_report(r"I:\project\3d\ detect\Complex-YOLOv4-Pytorch-master\dataset\kitti\testing\image_2") print(file_new)
31 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress