목표는 코드의 마지막 인쇄 행이지만 실제로이 오류가 계속 발생하기 때문에이 오류가 계속 발생합니다. TypeError:
'int
'및 'str
'에 대해 지원되지 않는 피연산자 유형이 지원됩니다. 가능한 한 출력 부품 만 빠르게 변경할 수 있습니까? 나는 여전히 그것들을 처음부터 int로 변환 할 필요가있다.하지만이 출력물의 경우에는 int 옆에 "Population"과 "Area"라는 단어가 필요하다!동일한 출력 줄에 여러 유형이 있습니다.
또는 인수로 그들에 전달하고 그것의 print
돌봐 보자 :
def _demo_fileopenbox():
msg = "Pick A File!"
msg2 = "Select a country to learn more about!"
title = "Open files"
default="*.py"
f = fileopenbox(msg,title,default=default)
writeln("You chose to open file: %s" % f)
countries = {}
with open(f,'r') as handle:
reader = csv.reader(handle, delimiter = '\t')
for row in reader:
countries[row[0]] = int(row[1].replace(',', '')), int(row[2].replace(',', ''))
reply = choicebox(msg=msg2, choices= list(countries.keys()))
print(reply)
print((countries[reply])[0])
print((countries[reply])[1])
#print(reply + "- \tArea: + " + (countries[reply])[0] + "\tPopulation: " + (countries[reply])[1])
네, 제가 게시 직후에 그걸 알아 들었습니다. output = reply + "- \ tArea :"+ str ((countries [reply]) [0]) + "\ tPopulation :"답장 = 선택 상자 (메시지 = msg2, 선택 = 목록 (countries.keys) + str (국가 [reply]) [] print (output)'답장을 보내 주셔서 감사합니다! – erp
@erp :'(foo) [0]'을 할 필요가 없습니다. 괄호없이'foo [0]'이라고 써주십시오. – Blender