我想用asciidoc创建一本pdf书.标题页应包括标题,副标题和图像.到目前为止,我找不到任何关于如何实现这一目标的文档.
我会做类似的事情
My book title
=============
:author: myself
:toc:
image:images/titelimage.png[width=400]
Run Code Online (Sandbox Code Playgroud)
但这只是image:images/titelimage.png[width=400]作为副标题添加.我想拥有的是什么
My book title
<titleimage>
subtitle
Run Code Online (Sandbox Code Playgroud)
有没有办法在ascciidoc中这样做?如果没有,我需要做什么才能得到这个?
我想从html文档中提取某些信息.例如,它包含一个表(在其他表中包含其他内容),如下所示:
<table class="details">
<tr>
<th>Advisory:</th>
<td>RHBA-2013:0947-1</td>
</tr>
<tr>
<th>Type:</th>
<td>Bug Fix Advisory</td>
</tr>
<tr>
<th>Severity:</th>
<td>N/A</td>
</tr>
<tr>
<th>Issued on:</th>
<td>2013-06-13</td>
</tr>
<tr>
<th>Last updated on:</th>
<td>2013-06-13</td>
</tr>
<tr>
<th valign="top">Affected Products:</th>
<td><a href="#Red Hat Enterprise Linux ELS (v. 4)">Red Hat Enterprise Linux ELS (v. 4)</a></td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
我想提取信息,如"发布日期:".看起来像BeautifulSoup4可以轻松地做到这一点,但不知何故,我无法做到这一点.我的代码到目前为止:
from bs4 import BeautifulSoup
soup=BeautifulSoup(unicodestring_containing_the_entire_htlm_doc)
table_tag=soup.table
if table_tag['class'] == ['details']:
print table_tag.tr.th.get_text() + " " + table_tag.tr.td.get_text()
a=table_tag.next_sibling
print unicode(a)
print table_tag.contents
Run Code Online (Sandbox Code Playgroud)
这将获取第一个表行的内容,以及内容列表.但是下一个兄弟的事情是行不通的,我想我只是错了.当然我可以解析内容,但在我看来,美丽的汤旨在阻止我们这样做(如果我开始解析自己,我不妨解析整个文档......).如果有人能够告诉我如何实现这一点,我将感激不尽.如果有更好的方式然后BeautifulSoup,我会有兴趣听到它.
我想编写一个可以在 Linux 和 Solaris 上执行的脚本。大多数逻辑在两个操作系统上都是相同的,因此我只编写了一个脚本。但是因为一些部署的结构会有所不同(文件位置、文件格式、命令语法),所以两个平台上的一些功能会有所不同。
这可以像这样处理
if 'linux' in sys.platform:
result = do_stuff_linux()
if 'sun' in sys.platform:
result = do_stuff_solaris()
more_stuf(result)
...
Run Code Online (Sandbox Code Playgroud)
然而,ifs在整个代码中散布这些似乎既麻烦又不优雅。我也可以在某些中注册函数dict,然后通过 dict 调用函数。大概好看一点。
关于如何做到这一点的任何更好的想法?
我正在尝试使用matplotlib中的表创建一个水平条形图.我几乎在那里,但未能将表格与图表对齐.到目前为止我得到了什么:
import matplotlib
matplotlib.use('Agg')
import numpy as np
import matplotlib.pyplot as plt
# Example data
appsol = ['llolLl', 'nnM', 'lllld bbbblnl', 'x2x', 'foobar', 'EXZ', 'Flups', 'Flaps', 'Foobar Barfooment', 'ABC', 'FABAS', 'common', 'AQT', 'Faberjak', 'simsalsa', 'LESS', 'Wermut']
y_pos = np.arange(len(appsol)) - .3
y_pos_2 = np.arange(len(appsol)) - .1
y_pos_3 = np.arange(len(appsol)) + .1
y_pos_4 = np.arange(len(appsol)) + .3
num_tickets = [4, 4,3,2,6,7,8,1,4,4,3,2,6,7,8,1,9]
num_tickets_2 = [7,6,5,4,3,4,2,1,2,4,1,0,3,0,2,1,0]
num_tickets_3 = [1,2,1,1,1,2,2,3,1,1,2,1,3,1,1,2,3]
num_tickets_4 = [8,7,6,2,13,6,8,9,7,6,5,4,3,6,8,9,12]
bar_width = .2
fig = plt.figure(figsize=(20,20))
ax = fig.add_subplot(111)
# correct …Run Code Online (Sandbox Code Playgroud) 我需要一些使用perls Getopt :: Lazy模块的帮助.我尝试了cpan页面中的示例:
#!/usr/bin/perl
#
#use warnings;
#use strict;
use Getopt::Lazy
'help|h' => 'Show this help screen',
'verbose|v' => 'Show verbose output',
'output|o=s' => ["[FILE] Send the output to FILE", 'getopt.out'],
'output-encoding=s' => ['[ENCODING] Specify the output encoding', 'utf8'],
-summary => 'a simple example usage of Getopt::Lazy',
-usage => '%c %o file1 [file2 ..]',
;
getopt;
print usage and exit 1 unless @ARGV;
Run Code Online (Sandbox Code Playgroud)
当我把它放在一个文件中执行它时./mygetopt.pl -h,我希望打印出帮助信息,但没有任何反应.当我没有-h参数调用它时,我希望它打印用法消息.没有这样的事情发生.此外,当我使用严格和警告时,我收到消息
Unquoted string "usage" may clash with future reserved word at …Run Code Online (Sandbox Code Playgroud)