以下是Selenium Python Bindings Library Documentation的导入示例:
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
这两个进口使用了很多。有没有办法做到以下几点:
答案 0 :(得分:1)
我使用yasnippet做类似的事情:
# -*- mode: snippet -*-
# contributor: jpkotta
# name: from __future__ import ...
# key: future
# --
from __future__ import print_function, division, unicode_literals, absolute_import
如果你不想打扰yasnippet,你可以做一个非常简单的命令:
(defun insert-foo ()
(interactive)
(let ((str "foo"))
(save-excursion
(save-restriction
(widen)
(goto-char (point-min))
(unless (search-forward-regexp (concat "^" (regexp-quote str)) nil t)
(goto-char (point-min))
(while (and (looking-at (concat "^" comment-start))
(not (eobp)))
(forward-line 1))
(insert str))))))
这足够聪明,可以在缓冲区的开头跳过注释,并且是幂等的,但不会自动运行。您可以编写命令来搜索另一个字符串“By”。并运行insert命令(如果已找到),然后将其添加到例如python-mode-hook
或before-save-hook
。