#计数版
class countdown(object):
	def __init__(self,start):
		self.start = start
	def __iter__(self):
		return countdown_iter(self.start)

class countdown_iter(object):
	def __init__(self, count):
		self.count = count
	def __next__(self):
		if self.count <= 0:
			raise StopIteration
		r = self.count
		self.count -= 1
		return r

  

#pandas读取多个文件
import pandas as pd

class read_csv_paths(object):
	def __init__(self,paths):
		self.paths = paths
	def __iter__(self):
		return read_csv_iter(self.paths)

class read_csv_iter(object):
	def __init__(self, paths):
		self.paths = paths
	def __next__(self):
		if len(self.paths)<=0:
			raise StopIteration
		path=self.paths.pop()
		#print(path)
		df=pd.read_csv(path,low_memory=False,dtype='object')
		return df

 

#generator版
def countdown(n):
	print("Counting down from", n)
	while n > 0:
		yield n
		n -= 1

  

  

相关文章:

  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2021-10-22
  • 2021-09-28
  • 2022-12-23
猜你喜欢
  • 2021-10-28
  • 2022-12-23
  • 2021-12-19
  • 2021-06-01
  • 2022-12-23
  • 2021-08-20
  • 2022-02-09
相关资源
相似解决方案