要分离抓取的数据列,可以使用Python中的字符串操作或正则表达式来实现。以下是一些示例代码,演示了如何根据不同的分隔符或格式将数据列分离。
data = "John,Doe,30,New York"
columns = data.split(",")
print(columns) # 输出: ['John', 'Doe', '30', 'New York']
import re
data = "John,Doe\t30\tNew York"
columns = re.split(",|\t", data)
print(columns) # 输出: ['John', 'Doe', '30', 'New York']
data = "John Doe 30 New York"
name = data[0:10].strip()
age = data[10:15].strip()
city = data[15:].strip()
print(name, age, city) # 输出: John Doe New York
注意:以上示例代码仅提供了一些常见的分离数据列的方法。实际上,根据数据的具体格式和要求,可能需要根据情况进行适当的修改。