当我打电话print给eval:
def printList(myList):
maxDigits = len(str(len(myList)))
Format = '0{0}d'.format(maxDigits)
for i in myList:
eval('print "#{0:' + Format + '}".format(i+1), myList[i]')
Run Code Online (Sandbox Code Playgroud)
它给出了一个错误:
print "#{0:01d}".format(i+1), myList[i]
^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)
我试着利用这个,然后重写它:
def printList(myList):
maxDigits = len(str(len(myList)))
Format = '0{0}d'.format(maxDigits)
for i in myList:
obj = compile(src, '', 'exec')
eval('print "#{0:' + Format + '}".format(i+1), myList[i]')
Run Code Online (Sandbox Code Playgroud)
但这抱怨i:
NameError: name 'i' is not defined
Run Code Online (Sandbox Code Playgroud)
PS我正在处理 python2.6
我将组织模式表转换为 table.el 表。为此,我选择了表格:
| Option | Type | Value | Descr |
| -[no]h | bool | yes | Print |
| -[no]versio | bool | no | Print |
| -nice | int | 0 | Set t |
| -[no]v | bool | no | Be lo |
| -time | real | -1 | Take |
| -[no]rmvsbd | bool | yes | Removvirtual |
| sites | | | |
| -maxwarn | int | 0 …Run Code Online (Sandbox Code Playgroud) 如何在电子邮件中插入内部链接?
这是我在浏览器中打开的html,在gmail中复制粘贴,发送给自己并希望其内部链接正常工作:
<html>
<body>
<p><a href="#Title1" title="Click to go to Title 1">Birds</a></p>
<p><a href="#Title2" title="Click to go to Title 2">Trees</a></p>
<p><a href="#Title3" title="Click to go to Title 3">Flowers</a></p>
<h4 id="Title1">Birds</h4>
<p> There are many different birds. There are... </p>
<h4 id="Title2">Trees</h4>
<p> Trees have many different colors and branches... </p>
<h4 id="Title3">Flowers</h4>
<p> The Lignum Vitae is the national flower of Jamaica... </p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
编辑:
我发送以下内容给自己:
<html>
<body>
<p><a href="#Title1" title="Click to go to Title 1">Birds</a></p>
<p><a href="#Title2" …Run Code Online (Sandbox Code Playgroud) 我想将{whitespace和yas/minor-mode}次模式挂钩到某些主要模式.当然,这可以手动完成,但我想要一个循环.所以我试着写下来:
(progn
(setq modes-to-be-hooked '(lisp-mode-hook rst-mode-hook python-mode-hook emacs-lisp-mode-hook text-mode-hook tcl-mode-hook c-mode-hook fortran-mode-hook))
(while modes-to-be-hooked
(setq my-hooks '( yas/minor-mode whitespace-mode ))
(while my-hooks
(add-hook '(pop modes-to-be-hooked) '(pop my-hooks)))
)
)
Run Code Online (Sandbox Code Playgroud)
这个循环的问题是list的最后一个元素是"nil"和(add-hook'nil'nil)给出了一个错误.然后我尝试用if来逃避nils但是它不起作用:
(progn
(setq mylist '(a b c))
(while mylist
(progn
(setq temp (pop mylist))
(if temp (message "%s" temp) (message "It's nil!") )
(sleep-for 1)
)
)
)
Run Code Online (Sandbox Code Playgroud)
打印零:(
我在KDE上,我需要找出并能够在脚本中切换当前的全局键盘布局.我做了一个研究setxkbmap- 但在这种情况下它没有任何帮助.
我如何阅读读数isearch-mode-map和global-map变量?随着C-h v它们以不可读的形式显示.
编辑:
C-h b 在查找键绑定时也很有用.
我写的脚本需要知道锡的原子质量.有没有python数据库有这样的信息?
编辑:
periodictable很好,但有些库更丰富的数据.例如gperiodic程序.
我想替换路径
(setq myFile "/some/path")
Run Code Online (Sandbox Code Playgroud)
在一个文件中。我尝试用 sed 来做到这一点:
find ./_build/html -type f -name '*.html' | while read myFile; do
MyFile=`readlink -f "$myFile"`
sed -i "s/setq myFile [)]*/setq myFile \"$MyFile\"/" sphinx_nowrap.el
# and then some actions on file
done
Run Code Online (Sandbox Code Playgroud)
和 perl:
find ./_build/html -type f -name '*.html' | while read myFile; do
MyFile=`readlink -f "$myFile"`
perl -ne "s/setq myFile .+/setq myFile \"$MyFile\")/" sphinx_nowrap.el
# and then some actions on file
done
Run Code Online (Sandbox Code Playgroud)
但两者都给出错误。
编辑:
这是一个 …