!curl https://raw.githubusercontent.com/MicrosoftLearning/intropython/master/worl
d_temp_mean.csv -o mean_temp.txt
weather = open('mean_temp.txt','a+')
weather.write('Rio de Janeiro,Brazil,30.0,18.0\n"')
weather.seek(0)
headings = weather.readline()
apple = headings.split(',')
city_temp = weather.readline()
orange = city_temp.split(',')
while city_temp:
orange = city_temp.split(',')
print (apple[2] + ' of ' + orange[1] + ' is ' + orange[2] + ' Celsius')
city_temp = weather.readline()
weather.close()
중리스트 인덱스는 이해가 안 돼요. 나는 while 루프가 문자열만을 받도록 보장하기 위해 readline과 split을 분리하려고 시도했다. 당신이 당신의 파일을 추가 할 때분할 및 readline에 오류가 왜 범위
당신도 오류 추적을 게시 할 수 있습니까 –
귀하의 질문에 대한 품질이 낮은 플래그가 지정되어 있으며, 나는 당신에게 리뷰 작성자로 남겨집니다. (1)'mean_temp.txt'라는 입력 파일의 내용을 보여줄 수 있다면 질문에 대답하기를 원하는 사람들에게 도움이 될 것입니다. (2)'apple'과'orange'와 같은 이름을 사용하면 코드를 읽기가 더 어렵게 만듭니다. 예를 들어,'apple'에 대해서 대신'heading_items'를 사용할 수 있습니다. (3) @KalyanReddy에 동의합니다. –