【发布时间】:2017-01-22 02:47:11
【问题描述】:
我想根据列表中的特定模式提取值。
**Example:**
ticker=['HF (NYSE) (81%);BPO (NEW YORK)]']
**Expected Output:**
Tickercode-HF;BPO
StockCode-NYSE;NEW YORK
Relevancescore-81;0
**My code**:
Tickercode=[x for x in ticker if re.match(r'[\w\.-]+[\w\.-]+', x)]
Stockcode=[x for x in ticker if re.match(r'[\w\.-]+(%)+[\w\.-]+', x)]
Relevancescore=[x for x in ticker if re.match(r'[\w\.-]+(%)+[\w\.-]+', x)]
**My output:**
['HF (NYSE) (81%);BPO (NEW YORK)]']
[]
[]
但是我得到了错误的输出。请帮我解决问题。
谢谢
【问题讨论】:
-
我在您的输出中没有看到任何错误。
-
没有出现错误。但我得到错误的输出