小编die*_*cht的帖子

带条件的xpath

如何使用复杂条件在Xpath中获取元素?

例如:

<?xml version="1.0" encoding="UTF-8"?>
<stock xmlns="http://localhost/aaabbb">
<item item-id="1">
 <name xml:format="short">This is a short name</name>
 <name xml:format="long">This is a LONG name</name>
</item>
</stock>
Run Code Online (Sandbox Code Playgroud)

目标:获取标签WHERE xml:format ="long"的文本.

在此先感谢您的帮助!

xml xpath

3
推荐指数
1
解决办法
2万
查看次数

无法使用python解析简单的json

我有一个非常简单的json我无法用simplejson模块解析.再生产:

import simplejson as json
json.loads(r'{"translatedatt1":"Vari\351es"}')
Run Code Online (Sandbox Code Playgroud)

结果:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/pymodules/python2.5/simplejson/__init__.py", line 307, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/pymodules/python2.5/simplejson/decoder.py", line 335, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/pymodules/python2.5/simplejson/decoder.py", line 351, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Invalid \escape: line 1 column 23 (char 23)
Run Code Online (Sandbox Code Playgroud)

任何人都知道什么是错的,以及如何正确解析上面的json?

在那里编码的字符串是:Variées

PS我使用python 2.5

非常感谢!

python json simplejson

3
推荐指数
1
解决办法
6801
查看次数

为什么MySQL为浮点数增加了额外的数字?

我有一张价格表.每个价格都是一个FLOAT,后面有两位数字.出于某种原因,当我在IF表达式中使用价格时,结果是具有许多附加数字的相同浮点数:

mysql> select price, IF(1, price,0) as my_price from tbl_prices limit 10;
+-------+------------------+
| price | my_price         |
+-------+------------------+
| 79.95 | 79.9499969482422 |
| 99.95 | 99.9499969482422 |
| 89.95 | 89.9499969482422 |
| 89.95 | 89.9499969482422 |
| 79.95 | 79.9499969482422 |
| 89.95 | 89.9499969482422 |
| 89.95 | 89.9499969482422 |
| 79.95 | 79.9499969482422 |
| 79.95 | 79.9499969482422 |
| 69.95 | 69.9499969482422 |
+-------+------------------+
10 rows in set (0.00 sec)
Run Code Online (Sandbox Code Playgroud)

如您所见,价格看起来不错,但IF表达式返回相同价格的结果 …

mysql

2
推荐指数
1
解决办法
684
查看次数

RedShift / ParAccel 中 UNION 选择查询的性能非常差

我在红移中有两个表:

  • tbl_current_day - 大约 450 万行
  • tbl_previous_day - 大约 450 万行,数据与 tbl_current_day 完全相同

除此之外,我还有一个名为qry_both_days的视图,定义如下:

CREATE OR REPLACE qry_both_days AS 
SELECT * FROM tbl_current_day
UNION SELECT * FROM tbl_previous_day;
Run Code Online (Sandbox Code Playgroud)

当我对其中一个单独的表运行查询时,我得到了预期的非常好的性能。例如,以下查询运行 5 秒:

select count(distinct person_id) from tbl_current_day;
-- (person_id is of type int)
Run Code Online (Sandbox Code Playgroud)

解释计划:

 XN Aggregate  (cost=1224379.82..1224379.82 rows=1 width=4)
   ->  XN Subquery Scan volt_dt_0  (cost=1224373.80..1224378.61 rows=481 width=4)
         ->  XN HashAggregate  (cost=1224373.80..1224373.80 rows=481 width=4)
               ->  XN Seq Scan on tbl_current_day  (cost=0.00..979499.04 rows=97949904 width=4)
Run Code Online (Sandbox Code Playgroud)

请注意,宽度是 4 个字节,因为它应该是,因为我的列是 int 类型。

但是,当我在 …

paraccel amazon-redshift

1
推荐指数
1
解决办法
6522
查看次数

标签 统计

amazon-redshift ×1

json ×1

mysql ×1

paraccel ×1

python ×1

simplejson ×1

xml ×1

xpath ×1