current position:Home>Python----import a local file and count the number of people surnamed Wang in the file, the function of the first character of the query string

Python----import a local file and count the number of people surnamed Wang in the file, the function of the first character of the query string

2022-11-08 07:19:50will be open today

The function of the first character of the query string:

      String to be queried.startswith('characters to be queried')

f=open("xg1903.csv",'r')stu=[]for line in f:line=line.replace('\n','')stu.append(line.split(','))print(stu)count=0for i in range(len(stu)):if stu[i][2].startswith('King'):count+=1print("The number of people whose name is king is {}".format(count))

copyright notice
author[will be open today],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/312/202211080628357757.html

Random recommended