gpt4 book ai didi

python - 如何跳过标准输入的第一行读取?

转载 作者:太空狗 更新时间:2023-10-30 00:50:05 27 4
gpt4 key购买 nike

 while 1:
try:
#read from stdin
line = sys.stdin.readline()
except KeyboardInterrupt:
break
if not line:
break
fields = line.split('#')
...

如何跳过 stdin 的第一行读取?

最佳答案

infile = sys.stdin
next(infile) # skip first line of input file
for line in infile:
if not line:
break
fields = line.split('#')
...

关于python - 如何跳过标准输入的第一行读取?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24796541/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com