一個目錄中有很多子目錄。每個子目錄名稱都以日期結尾。我想打開一個以今天的日期結尾的子目錄。
到目前為止,這是我的代碼。但它不作業。
import datetime
now = datetime.datetime.now()
currentdate = now.strftime("%d")
currentmonth = now.strftime("%B")
print(currentdate)
print(currentmonth)
path = 'C:\\Users\\Mondoc\\Desktop\\SweetMemories'
for folder in path:
if folder.endswith(currentdate):
pathtofolder = folder
import subprocess
subprocess.Popen('C:\\Users\\Mondoc\\Desktop\\SweetMemories' pathtofolder)
我的代碼不起作用
uj5u.com熱心網友回復:
您實際上是在迭代一個字串。這是你想要的嗎?
import os
# for folder in path:
# if folder.endswith(currentdate):
for name in os.listdir(path):
if os.path.isdir(name) and name.endswith(...):
...
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/487170.html
標籤:python-3.x 约会时间 目录 子进程 以。。结束
