我正在努力转换
a | a1,a2,a3
b | b1,b3
c | c2,c1
Run Code Online (Sandbox Code Playgroud)
至:
a | a1
a | a2
a | a3
b | b1
b | b2
c | c2
c | c1
Run Code Online (Sandbox Code Playgroud)
以下是sql格式的数据:
CREATE TABLE data(
"one" TEXT,
"many" TEXT
);
INSERT INTO "data" VALUES('a','a1,a2,a3');
INSERT INTO "data" VALUES('b','b1,b3');
INSERT INTO "data" VALUES('c','c2,c1');
Run Code Online (Sandbox Code Playgroud)
解决方案可能是递归的公共表表达式。
这是一个与单行相似的示例:
WITH RECURSIVE list( element, remainder ) AS (
SELECT NULL AS element, '1,2,3,4,5' AS remainder
UNION ALL
SELECT
CASE
WHEN INSTR( remainder, ',' )>0 THEN …Run Code Online (Sandbox Code Playgroud) 我试图解析来自Savon SOAP api的SOAP响应
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:getConnectionResponse xmlns:ns="http://webservice.jchem.chemaxon">
<ns:return>
<ConnectionHandlerId>connectionHandlerID-283854719</ConnectionHandlerId>
</ns:return>
</ns:getConnectionResponse>
</soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)
我试图使用libxml-ruby而没有任何成功.基本上我想提取标签内的任何内容和connectionHandlerID值.
下列
>>> re.sub(r'(\d+)', r'\1' * 2, 'test line 123')
Run Code Online (Sandbox Code Playgroud)
给
'test line 123123'
Run Code Online (Sandbox Code Playgroud)
有没有办法让它给
'test line 246'
Run Code Online (Sandbox Code Playgroud)
?
float() 胁迫不起作用:
>>> re.sub(r'(\d+)', float(r'\1') * 2, 'test line 123')
could not convert string to float: \1
Run Code Online (Sandbox Code Playgroud)
也不做eval或exec.
我想在当前缓冲区的位置运行一个脚本,或者,如果它是一个直接缓冲区,则在当前的dired目录上运行脚本.当前的dired目录似乎存储在dired-directory变量中.确实是 - 但是当我尝试使用它时 - 它有时会给我以前的目录而不是现在的目录:
(defun bk-konsoles ()
"Calls: bk-konsoles.bash"
(interactive)
(let ((curDir (if (memq major-mode '(dired-mode sr-mode)) dired-directory
(if (buffer-file-name) (file-name-directory (buffer-file-name))))))
(shell-command (concat (expand-file-name "~/its/plts/goodies/bk-konsoles.bash ") curDir " & disown") nil nil)
(kill-buffer "*Shell Command Output*")
(delete-other-windows)))
Run Code Online (Sandbox Code Playgroud)
如何让defun获得dired当前目录的正确值?
这是一种在非root运行emacs中打开根文件的方法:
erf () { SUDO_EDITOR="emacsclient -n -a emacs" sudoedit $@; } ;; erf = Emacs Root Foreground
Run Code Online (Sandbox Code Playgroud)
它会询问root密码,输入后会打开一个文件副本/tmp.例:
$ cd /etc/apt
$ erf sources.list
Run Code Online (Sandbox Code Playgroud)
打开:sourcesXXiOSmYN.list.所以我编辑了这个东西,并用C-x C-s它保存 - 但它没有保存:
$ sudoedit: sources.list unchanged
Run Code Online (Sandbox Code Playgroud)
如何保存它?(功能非常整洁)
编辑:
erf () { SUDO_EDITOR="emacsclient -a emacs" sudoedit $@; } ;; erf = Emacs Root Foreground
Run Code Online (Sandbox Code Playgroud)
扼杀它.保存文件,然后 - 删除缓冲区或C-x #.有用.
在os那里有一个os.path.islink(PATH)检查是否PATH是符号链接的函数.但是当PATH是某个目录的符号链接时失败.相反 - python认为它是directory(os.path.isdir(PATH)).那么如何检查目录是否链接?
编辑:
这是bash想法:
~/scl/bkbkshit/Teaching: file 2_-_Classical_Mechanics_\(seminars\)
2_-_Classical_Mechanics_(seminars): symbolic link to `/home/boris/wrk/tchn/2_-_Classical_Mechanics_(seminars)'
Run Code Online (Sandbox Code Playgroud)
这是什么python想法:
In [8]: os.path.islink("2_-_Classical_Mechanics_(seminars)/")
Out[8]: False
Run Code Online (Sandbox Code Playgroud) 我刚刚升级到Kubuntu 11.10.之后,Emacs在空白空间模式中表示空格的方式发生了变化.这是阴影矩形,而不是Emacs在白色空间的地方放点:

我试图通过M-x customize-group然后改变它whitespace- 但是没有像点那样的东西.它说空白用阴影表示(见上图) - 但它们不是(见同一张图片).
这是空白空间面的价值:

我也在超级用户那里问过这个问题但是因为我在那里得到了0个回复 - 我决定咨询另一个社区.
编辑1:
遵循Luke的解决方案不会给空间或标签带来任何颜色(除非我做错了):

编辑2:
添加face此处修复了Luke的解决方案.谢谢谢尔盖.
(setq whitespace-style (quote
( face spaces tabs newline space-mark tab-mark newline-mark)))
Run Code Online (Sandbox Code Playgroud)
编辑3:
目前我正在使用:
(custom-set-variables
'(whitespace-line-column 9999999)
'(whitespace-tab-width 4 t)
'(whitespace-display-mappings '(
(space-mark ?\ [?\u00B7] [?.]) ; space - centered dot
(space-mark ?\xA0 [?\u00A4] [?_]) ; hard space - currency
(newline-mark ?\n [?$ ?\n]) ; eol - dollar sign
(tab-mark ?\t [?\u00BB ?\t] [?\\ ?\t]) …Run Code Online (Sandbox Code Playgroud) 当我打电话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
如何在电子邮件中插入内部链接?
这是我在浏览器中打开的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) 这是一个简单的程序:
#!/usr/bin/env python3
l = list(range(5))
print(l, type(l))
l = list(range(5)).remove(2)
print(l, type(l))
Run Code Online (Sandbox Code Playgroud)
由于某种原因,列表在删除元素时被销毁:
[0, 1, 2, 3, 4] <class 'list'>
None <class 'NoneType'>
Run Code Online (Sandbox Code Playgroud)
(是节目输出)
我希望它输出
[0, 1, 3, 4]
Run Code Online (Sandbox Code Playgroud)
有什么问题,如何从生成的列表中删除元素range?