testling

def file_name(file_dir):
"""
获取文件夹下面的pdf文件——第一个for循环
获取得到的pdf文件包含“-Y”的文件——第二个for循环
:param file_dir:
:return:
"""
file_name=[]

for files in os.listdir(unicode(file_dir,\'utf-8\')):

if os.path.splitext(files)[1]==\'.pdf\':

file_name.append(files)

for files in file_name:
if "-Y" in files:
print files



存在两个循环 获取某个文件夹下的带有.pdf的文件名称 如果是打印全部文件名称,就去掉.pdf


第二个for循环是得到的pdf文件,取带有“-Y”的文件

大家试试吧

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-08-27
  • 2021-12-23
  • 2022-12-23
  • 2022-01-11
  • 2021-05-22
  • 2021-05-14
  • 2021-08-31
猜你喜欢
  • 2021-10-20
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2022-01-06
  • 2021-07-19
相关资源
相似解决方案