Python 将列表打印成一行
我想知道我怎样才能把代码打印成一行。我希望图像的完整路径在一行中,用空格隔开,但我尝试了很多方法,但由于某些原因,我似乎无法使其工作。代码如下:Python 将列表打印成一行,python,python-3.x,Python,Python 3.x,我想知道我怎样才能把代码打印成一行。我希望图像的完整路径在一行中,用空格隔开,但我尝试了很多方法,但由于某些原因,我似乎无法使其工作。代码如下: import os import datetime as dt now = dt.datetime.now() ago = now-dt.timedelta(minutes=5) for root, dirs,files in os.walk('C:/xxxx/xxxx/xxxx/xxxx/Images'): for fname in fi
import os
import datetime as dt
now = dt.datetime.now()
ago = now-dt.timedelta(minutes=5)
for root, dirs,files in os.walk('C:/xxxx/xxxx/xxxx/xxxx/Images'):
for fname in files:
path = os.path.join(root, fname)
st = os.stat(path)
ctime = dt.datetime.fromtimestamp(st.st_ctime)
if ctime > ago:
print(path.replace('Images\\', 'Images/'))
打印时可以显式设置结束字符:
print(path.replace('Images\\', 'Images/'), end=' ')
打印时可以显式设置结束字符:
print(path.replace('Images\\', 'Images/'), end=' ')