1、安装pymemcache
pip install pymemcache
2、建立testMemcached.py
vim testMemcached.py
输入以下代码:
from pymemcache.client.base import Client
client = Client(('localhost', 11211)) # 链接数据库
client.set('mykey', 'myvalue') # 添加数据
result = client.get('mykey') # 查询 mykey 键
print(result) # 输出结果