I am using an api which searches for tvshows and returns an id, the issue I have is that if I save the search as a variable and print the variable it returns output like this:
for result in show:
a = (result.id)
print(a)
84661
30191
30287
80987
111713
8108
50813
72444
42117
22306
4807
I want to save the first result as a variable that I can use later. Have tried a few different things like os.system("echo " + a + " | head -1")
but this returns 4807 not 84661, same for awk and sed. What am I doing wrong? I've tried saving the variable as list, str and array but am unable to grab just the first line, It keeps getting the last one.
question from:
https://stackoverflow.com/questions/65948424/python-how-to-save-first-line-of-stdout-as-a-variable 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…