Python 提取想要的元素

数据处理中遇到的

a = '''
充值12999点券     项目    12999_coupons
充值16999点券     项目    16999_coupons

'''
array = a.split('\n')  # 字符串转换为array数组
# print(array)
for obj in array:
    if obj != "":  # 去掉空格
        tempArray = obj.split('\t')  # 去掉//
        # print(tempArray)
        url = tempArray[2]  # 提取第二位元素
        print(url)

结果为:

12999_coupons
16999_coupons

猜你喜欢

转载自www.cnblogs.com/qiqi-yhq/p/12073638.html