메신저 프로그램에서 함수를 사용하려하지만 완전히 작동하지 않는 방법으로 파이썬을 사용하고 있지만 사용하지 않은 함수는 아무도 왜이 기능이 작동하지 않는지 설명 할 수 없습니다. 부디?파이썬에서 함수를 호출하는 방법
import csv
import operator
def SerachForCapitals():
#opens and reads txt file
sample = open('Capitals.txt', 'r')
csv1 = csv.reader(sample, delimiter = ',')
#asks user for an input
name = raw_input('enter a capital: ')
#sets the headings
print ""
print "Capital, Country"
print ""
#Finds capital row and prints it
for row in csv1:
if name == row[0]:
print row
print ' '
def AddInData():
#opens the text file
sample = open('capitals.txt','a+')
csv1 = csv.reader(sample, delimiter = ',')
#prints headings
print 'capital, country'
#ask ser for an input
change = raw_input('add data like line shown above:')
#adds input to text file
sample.write(change)
#closes the text file
sample.close()
#Menu choices
print '1. choose a capital'
print '2. enter data'
#Get an input from the user
menuC= raw_input('please choose a menu item: ')
if menuC == '1':
SearchForCapitals()
elif menuC == '2':
AddInData()
_ "왜이 기능이 작동하지 않는지 설명 할 수 있습니까?"_ 어떻게 작동하지 않습니까? 오류 메시지가 표시되고 있습니까, 아니면 무엇입니까? – Kevin
일부 문서를보십시오. 힌트 : 이미'open'과'raw_input'을 포함한 몇 가지 함수를 사용했습니다. –