python获取目录下文件名称不带后缀_python 文件操作 练习:把一个目录下的所有文件名,打印一下,不要包含后缀名...

#coding=utf-8

import os

os.chdir('d:\\test2')

file_list=os.listdir('.')

print "file_list:",file_list

print "*"*100

for file in file_list:

print os.path.splitext(file)[0]

c:\Python27\Scripts>python task_test.py

file_list: ['3rdParty Access - RequestForm_Team - APAC - v2 edited by TC.docx', 'carton status.xlsx', 'Copy of IT Shifts on Feb and Mar. 2.27-3.18.xlsx', 'DB connection', 'EXPORT', 'export.xlsx', 'export0131.xlsx', 'handle data format for sql.docx', 'handover', 'Issue archivement.pst', 'New Microsoft Excel Worksheet.xlsx', 'pkt status.xlsx', 'Short_Health Check guide.docx', 'Support Note.xlsx', 'Support Note_bkp.xlsx', 'support summary.docx', '~$actice.docx', '~$ort_Health Check guide.docx', '~$pport summary.docx', '~$Support Note.xlsx', '~WRL0003.tmp', '~WRL1399.tmp', '?? Microsoft Office Word Document.docx']

****************************************************************************************************

3rdParty Access - RequestForm_Team - APAC - v2 edited by TC

carton status

Copy of IT Shifts on Feb and Mar. 2.27-3.18

DB connection

EXPORT

export

export0131

handle data format for sql

handover

Issue archivement

New Microsoft Excel Worksheet

pkt status

Short_Health Check guide

Support Note

Support Note_bkp

support summary

~$actice

~$ort_Health Check guide

~$pport summary

~$Support Note

~WRL0003

~WRL1399

?? Microsoft Office Word Document

你可能感兴趣的:(python获取目录下文件名称不带后缀_python 文件操作 练习:把一个目录下的所有文件名,打印一下,不要包含后缀名...)