Scott Logistics Corp
Transportation One LLC
Brothers Logistics Inc
Western Express Inc
Dart Advantage Logistics
Western Express Inc
Western Express Inc
Landstar Inway
Circle Logistics Inc查看上面的数据集我想将每个名称添加到双引号中,例如("Scott物流公司“),或者看到下面我想要对此数据集做什么。
"Scott Logistics Corp"
"Transportation One LLC"
"Brothers Logistics Inc"
"Western Express Inc"
"Dart Advantage Logistics"
"Western Express Inc"
"Western Express Inc"
"Landstar Inway"
"Circle Logistics Inc"
....我将从-1\f25 .txt -1文件中的-1\f25 dataset-1读取数据,并希望将其更改为-1\f25 dataset-1\f6,每个名称都用双引号括起来。
发布于 2019-12-31 19:58:57
如果你想添加双引号,那么纯python就足够了:
with open(r"text_1.txt",'r') as file:
for line in file:
line = re.sub(r'\n','',line)
lines_new = (f'"{line}\"\n')
with open("text_2.txt", "a") as f1:
f1.writelines(lines_new)
"Scott Logistics Corp"
"Transportation One LLC"
"Brothers Logistics Inc"
"Western Express Inc"
"Dart Advantage Logistics"
"Western Express Inc"
"Western Express Inc"
"Landstar Inway"
"Circle Logistics Inc"https://stackoverflow.com/questions/59543480
复制相似问题