码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2018-04-20 14:30:33      阅读:475      评论:0      收藏:0      [点我收藏+]

标签:over   note   access   rto   rip   task   ice   sof   art   

#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 文件操作 练习:把一个目录下的所有文件名,打印一下,不要包含后缀名

标签:over   note   access   rto   rip   task   ice   sof   art   

原文地址:https://www.cnblogs.com/xiaxiaoxu/p/8890509.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!