并非所有行都是从我的 CSV 文件中打印出来的
Not all the rows are printed from my CSV file
并非所有行都从我的 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()
并非所有行都从我的 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()