如何在csv文件中切断根字符串周围的字符串?有什么解决办法吗?
我在另一个专栏的句子中有我的根字符串
例如,我有:
lack of association between the promoter polymorphism of the mtnr1a gene and adolescent idiopathic scoliosis
我的根字符串:mtnr1a,我想要输出:
promoter polymorphism of the mtnr1a gene and adolescent idiopathic
Tags:
如果您只想在“根字符串”第一次出现的两边各有4个单词,可以使用:
将句子转换成单词列表,然后找到根字符串的索引应该可以完成以下工作:
结果:
注意:当在句子中找不到根字符串时,需要捕获
ValueError
。在这种情况下,cutoff
被设置为None
相关问题 更多 >
编程相关推荐