Author: nullnull
Date: Jul 21, 2008 18:34
※ 引述《kenduest (小州)》之銘言:
> ※ 引述《jeffreychen.bbs@ptt.cc》之銘言:
>> 請問一下
>> 我想判斷aaa檔名的檔案存不存在
>> 在python要如何寫呢
> import os.path
> if os.path.exists("aaa") :
> print "exist"
> else:
> print "not exist"
接龍 :P
import os
exists = lambda f : (os.path.exists(f) and "exists") or "not exist"
print exists('test.py')
--
FP-like 的寫法
|