繁体   English   中英

如何使用 find.() 从一行字符串中提取特定字符串

[英]How to extract certain string from a line of string using find.()

file_name_to_preprocessing_method("heloc_dataset_v1(exc empty rows.).csv_pre(-1,asis).csv")

应该返回字符串“(-1,asis)”,可能使用.find()

在此处输入图像描述

re.findall用于正则表达式方法:

inp = "file_name_to_preprocessing_method(\"heloc_dataset_v1(exc empty rows.).csv_pre(-1,asis).csv\")"
matches = re.findall(r'\bcsv_pre(\(.*?\))', inp)
print(matches[0])  # (-1,asis)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM