---
title: "python"
author: "ericFang"
date: "2009-09-04T15:18:03Z"
tags: []
categories: ["编程语言"]
slug: "python"
draft: false
lastmod: "2009-09-04T15:18:03Z"
id: 462145
url: "https://ericfang.iteye.com/blog/462145"
---

import os  
filenames=os.listdir(os.getcwd())  
num=raw\_input('請輸入一個數字:')  
for name in filenames:  
 filenames\[filenames.index(name)]=name\[:-int(num)]  
out=open('names.txt','w')  
for name in filenames:  
 out.write(name+'\\n')  
out.close()

 

 

try:  
 filename=raw\_input("eric")  
 fobj=open(filename,'r')  
 for eachLine in fobj:  
  print eachLine,  
 fobj.close()  
except IOError e: