2024-10-06 12:19:49 发布
网友
最终输出只能是1368083列中的数字
使用str.split
str.split
s1 = "Row1_1368083_US_PBPR_STD" s2 ="Row215_1368083_US_PBPR_ENH" print(s1.split("_")[1]) print(s2.split("_")[1])
输出:
1368083 1368083
或者正则表达式。你知道吗
import re s1 = "Row216_60902413_US_PBPR_ENH" s2 ="Row227_37758281_US_PBPR_ENH" print(re.findall(r"\d{6,}", s1)[0]) print(re.findall(r"\d{6,}", s2)[0])
awk -F_ '$2 ~/1368083/{print $2}' file 1368083 1368083
使用sed提取两个‘’
sed
sed 's/^.*_\([0-9]*\)_.*/\1/'
或者使用awk提取第二个字段,该字段由‘’
awk
awk -F'_' '{print $2}'
使用
str.split
输出:
或者正则表达式。你知道吗
使用
sed
提取两个‘’或者使用
awk
提取第二个字段,该字段由‘’相关问题 更多 >
编程相关推荐