不是所有的行都是从我的CSV文件中打印出来的,它只打印第一行,然后再次返回while
循环。我想在后面添加另一个函数来打印所有行,但由于某种原因它不能工作。
import csv
import pandas as pd
import stdiomask
def volleyball_court():
print("Volleyball Courts")
print()
with open("location.csv", "r") as csvfile:
csvreader = csv.reader(csvfile, delimiter=',')
location = (input("Enter your suburbs:")
for row in csvreader:
if location in str(row[0]):
print(row)
return_menu()
你在if语句中调用了return_menu(),把它移出for循环,你就可以了
for row in csvreader:
if location in str(row[0]):
print(row)
return_menu()