import timeclass AD(): pass def __init__(self,content,direction,speed): self.content = content self.direction = direction self.speed = speed def start(self): while True: print(self.content, end='\r') if self.direction == "1": self.content = self.content[1:]+self.content[0] elif self.direction == '2': self.content = self.content[-1]+self.content[:-1] if self.speed == "快": time.sleep(0.25) elif self.speed == '中': time.sleep(0.5) elif self.speed == '慢': time.sleep(1)if __name__ == "__main__": content = input('请输入广告语: ') direction = input('请选择方向, 从右往左请选1, 从左往右请选2... ') speed = input('请选择滚动速度: 快, 中, 慢... ') ad = AD(content,direction,speed) ad.start()复制代码
快速跳转:
猫哥教你写爬虫 028--模块介绍-小作业-广告牌.md