看板 Python 關於我們 聯絡資訊
※ 引述《yjc1 (..........)》之銘言: : ※ 引述《qrtt1.bbs@bbs.cs.nctu.edu.tw (null)》之銘言: : : 接龍 :P : : import os : : exists = lambda f : (os.path.exists(f) and "exists") or "not exist" : : print exists('test.py') : ............... 這樣倒不如直接寫 : print ('not exist', 'exists')[os.path.exists("aaa")] print "exists" if os.path.exists(f) else "not exist" 都什麼年代了還在用 logic operator? :p Python 3.0: print("exists" if os.path.exists(f) else "not exist") -- back to work. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 164.107.170.191