我正在使用 Python 3 循环遍历包含字符串的 .txt 文件的行。这些字符串将在curl 命令中使用。但是,它仅适用于文件的最后一行。我相信其他行以换行符结尾,这会导致字符串丢失:
url = https://
with open(file) as f:
for line in f:
str = (url + line)
print(str)
这将返回:
https://
endpoint1
https://
endpoint2
https://endpoint3
如何解决所有字符串像最后一行一样连接的问题?
青春有我
互换的青春
小唯快跑啊
相关分类