ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
## 什么是代码? 代码是现实世界事物在计算机世界中的映射 ## 什么是写代码? 写代码是将现实世界中的事物用计算机语言来描述 [Urllib库的基本使用](http://www.cnblogs.com/zhaof/p/6910871.html) Redis ``` #!/usr/bin/python3 import redis class BaseRedis: def __init__(self): if not hasattr(BaseRedis, 'pool'): BaseRedis.create_pool() self._connection = redis.Redis(connection_pool = BaseRedis.pool) @staticmethod def create_pool(): BaseRedis.pool = redis.ConnectionPool(host = '127.0.0.1') @staticmethod def instance(): return self._connection r = BaseRedis.instance print(r) ```