我目前正在使用PIL.
from PIL import Image
try:
im=Image.open(filename)
# do stuff
except IOError:
# filename not an image file
Run Code Online (Sandbox Code Playgroud)
但是,尽管这足以涵盖大多数情况,但未检测到某些图像文件,如xcf,svg和psd.Psd文件抛出OverflowError异常.
有没有我可以包括他们?
嗨,我已经使用Emacs23一段时间了,发现它是一个非常酷的编辑器.但是我对光标(或Emacs术语中的点)是一个"小黑盒子"感到不满意.我想要它是一个很好的细直线,就像它在gedit或记事本中的方式.有关如何做到这一点的任何建议?
我正在使用此页面上列出的ido方法:http://www.emacswiki.org/emacs/RecentFiles .我希望能够选择它存储的最近文件的数量.它似乎不存储很多.是否有这样的设置或简单的方法.下面列出的功能供参考.干杯
(defun recentf-interactive-complete ()
"find a file in the recently open file using ido for completion"
(interactive)
(let* ((all-files recentf-list)
(file-assoc-list (mapcar (lambda (x) (cons (file-name-nondirectory x) x)) all-files))
(filename-list (remove-duplicates (mapcar 'car file-assoc-list) :test 'string=))
(ido-make-buffer-list-hook
(lambda ()
(setq ido-temp-list filename-list)))
(filename (ido-read-buffer "Find Recent File: "))
(result-list (delq nil (mapcar (lambda (x) (if (string= (car x) filename) (cdr x))) file-assoc-list)))
(result-length (length result-list)))
(find-file
(cond
((= result-length 0) filename)
((= result-length 1) (car result-list))
( …Run Code Online (Sandbox Code Playgroud)