You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Python中从长字符串提取以?开头的子串并生成列表

提取SPARQL查询中的所有变量

首先,先把你提供的原始SPARQL查询放出来方便对照:

PREFIX pht: <http://datalab.rwth-aachen.de/vocab/pht/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?Age, ?SexTypes, ?Chest_Pain_Type, ?trestbpsD, ?cholD, ?Fasting_Glucose_Level, ?Resting_ECG_Type, ?thalachD, ?Exercise_Induced_Angina, ?oldpeakD, ?caD, ?Slope, ?Thallium_Scintigraphy, ?Diagnosis WHERE {?URI a sct:125676002. }

我已经把所有以?开头的变量提取出来,整理成列表如下:

  • ?Age
  • ?SexTypes
  • ?Chest_Pain_Type
  • ?trestbpsD
  • ?cholD
  • ?Fasting_Glucose_Level
  • ?Resting_ECG_Type
  • ?thalachD
  • ?Exercise_Induced_Angina
  • ?oldpeakD
  • ?caD
  • ?Slope
  • ?Thallium_Scintigraphy
  • ?Diagnosis
  • ?URI

内容的提问来源于stack exchange,提问作者Martin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:55:46