客户端的操作

zkCli.sh

官方文档

  1. ls /

[zookeeper]

  1. get /

cZxid = 0x0

ctime = Thu Jan 01 08:00:00 CST 1970

mZxid = 0x0

mtime = Thu Jan 01 08:00:00 CST 1970

pZxid = 0x0

cversion = -1

dataVersion = 0

aclVersion = 0

ephemeralOwner = 0x0

dataLength = 0

numChildren = 1

  1. create /test 123

Created /test

  1. set /test 456

cZxid = 0x2

ctime = Wed Mar 28 11:20:40 CST 2018

mZxid = 0x3

mtime = Wed Mar 28 11:21:22 CST 2018

pZxid = 0x2

cversion = 0

dataVersion = 1

aclVersion = 0

ephemeralOwner = 0x0

dataLength = 3

numChildren = 0

  1. delete /test

Java API

创建会话

  1. public class ZkDemon4java implements Watcher {
  2. private static CountDownLatch countDownLatch = new CountDownLatch(1);
  3. public void process(WatchedEvent watchedEvent) {
  4. System.out.println("receive wathedEvent:" + watchedEvent);
  5. if (Event.KeeperState.SyncConnected == watchedEvent.getState()) {
  6. countDownLatch.countDown();
  7. }
  8. }
  9. public static void main(String[] args) throws IOException, InterruptedException {
  10. ZooKeeper zooKeeper = new ZooKeeper("192.168.2.192:2181", 5000, new ZkDemon4java());
  11. System.out.println("zk status:" + zooKeeper.getState());
  12. countDownLatch.await();
  13. }
  14. }

输出:

  1. zk status:CONNECTING
  2. receive wathedEvent:WatchedEvent state:SyncConnected type:None path:null

使用sessionId,sessionPasswd

  1. ZooKeeper zooKeeper = new ZooKeeper("192.168.2.192:2181", 5000, new ZkDemon4java());
  2. System.out.println("zk status:" + zooKeeper.getState());
  3. countDownLatch.await();
  4. long sessionId = zooKeeper.getSessionId();
  5. byte[] sessionPasswd = zooKeeper.getSessionPasswd();
  6. zooKeeper = new ZooKeeper("192.168.2.192:2181", 5000, new ZkDemon4java(), sessionId, sessionPasswd);
  7. zooKeeper = new ZooKeeper("192.168.2.192:2181", 5000, new ZkDemon4java(), sessionId, "123456".getBytes());
  8. Thread.sleep(Integer.MAX_VALUE);

结果:

  1. zk status:CONNECTING
  2. receive wathedEvent:WatchedEvent state:SyncConnected type:None path:null
  3. receive wathedEvent:WatchedEvent state:SyncConnected type:None path:null
  4. receive wathedEvent:WatchedEvent state:Expired type:None path:null
  5. receive wathedEvent:WatchedEvent state:Disconnected type:None path:null
  6. receive wathedEvent:WatchedEvent state:Disconnected type:None path:null
  7. receive wathedEvent:WatchedEvent state:SyncConnected type:None path:null

Expired 是使用错误sessionPasswd的结果

至于结果中的不断地SyncConnected,Disconnected尚不清楚。

创建节点

同步执行:创建临时节点,临时顺序节点
  1. //sync
  2. String s = zooKeeper.create("/test1", "value1".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
  3. System.out.println("success create path:" + s);
  4. s = zooKeeper.create("/test1", "value1".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
  5. System.out.println("success create path:" + s);

结果:

  1. zk status:CONNECTING
  2. receive wathedEvent:WatchedEvent state:SyncConnected type:None path:null
  3. success create path:/test1
  4. success create path:/test10000000001

临时,顺序在zkCli用-e, -s指定,临时节点会在会话结束时删除,顺序节点会自动添加序号。

同步执行:
  1. public class ZkDemon4java implements Watcher {
  2. private static CountDownLatch countDownLatch = new CountDownLatch(1);
  3. public void process(WatchedEvent watchedEvent) {
  4. System.out.println("receive wathedEvent:" + watchedEvent);
  5. if (Event.KeeperState.SyncConnected == watchedEvent.getState()) {
  6. countDownLatch.countDown();
  7. }
  8. }
  9. public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
  10. ZooKeeper zooKeeper = new ZooKeeper("192.168.2.192:2181", 5000, new ZkDemon4java());
  11. System.out.println("zk status:" + zooKeeper.getState());
  12. countDownLatch.await();
  13. IStringCallBack iStringCallBack = new ZkDemon4java().new IStringCallBack();
  14. //async
  15. zooKeeper.create("/test1", "value1".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL, iStringCallBack, "i am ctx");
  16. zooKeeper.create("/test1", "value1".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL, iStringCallBack, "i am ctx");
  17. zooKeeper.create("/test1", "value1".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL, iStringCallBack, "i am ctx");
  18. Thread.sleep(Integer.MAX_VALUE);
  19. }
  20. class IStringCallBack implements AsyncCallback.StringCallback {
  21. public void processResult(int i, String s, Object o, String s1) {
  22. System.out.println("Create Path result resultCode:" + i + ",path:" + s + ",ctx:" + o.toString() + ",real path name:" + s1);
  23. }
  24. }
  25. }

结果:

  1. zk status:CONNECTING
  2. receive wathedEvent:WatchedEvent state:SyncConnected type:None path:null
  3. Create Path result resultCode:0,path:/test1,ctx:i am ctx,real path name:/test1
  4. Create Path result resultCode:-110,path:/test1,ctx:i am ctx,real path name:null
  5. Create Path result resultCode:0,path:/test1,ctx:i am ctx,real path name:/test10000000009

删除节点

  1. zooKeeper.delete("/test", -1);

其中version=-1表示不论节点的dataVersion是什么都删除,如果指定一个大于-1的数,则只当version不一样时不能删除。

读取数据

getChildren(同步)

  1. public class ZkDemon4java implements Watcher {
  2. private static CountDownLatch countDownLatch = new CountDownLatch(1);
  3. private static ZooKeeper zooKeeper;
  4. public void process(WatchedEvent watchedEvent) {
  5. System.out.println("receive wathedEvent:" + watchedEvent);
  6. if (Event.KeeperState.SyncConnected == watchedEvent.getState()) {
  7. if (watchedEvent.getType() == Event.EventType.None && null == watchedEvent.getPath()) {
  8. countDownLatch.countDown();
  9. } else if (Event.EventType.NodeChildrenChanged == watchedEvent.getType()) {
  10. try {
  11. //if you need get advice again you must set watch:true
  12. System.out.println("ReGet child:" + zooKeeper.getChildren(watchedEvent.getPath(), false));
  13. } catch (KeeperException e) {
  14. e.printStackTrace();
  15. } catch (InterruptedException e) {
  16. e.printStackTrace();
  17. }
  18. }
  19. }
  20. }
  21. public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
  22. zooKeeper = new ZooKeeper("192.168.2.192:2181", 5000, new ZkDemon4java());
  23. System.out.println("zk status:" + zooKeeper.getState());
  24. countDownLatch.await();
  25. String path = "/zk_book";
  26. zooKeeper.create(path, "123".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
  27. //get children List and register Watch
  28. System.out.println("get child result:" + zooKeeper.getChildren(path, new ZkDemon4java()));
  29. zooKeeper.create(path + "/c1", "123".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
  30. zooKeeper.create(path + "/c2", "123".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
  31. Thread.sleep(Integer.MAX_VALUE);
  32. }
  33. }

System.out.println("ReGet child:" + zooKeeper.getChildren(watchedEvent.getPath(), false));一次通知

  1. zk status:CONNECTING
  2. receive wathedEvent:WatchedEvent state:SyncConnected type:None path:null
  3. get child result:[]
  4. receive wathedEvent:WatchedEvent state:SyncConnected type:NodeChildrenChanged path:/zk_book
  5. ReGet child:[c1]

System.out.println("ReGet child:" + zooKeeper.getChildren(watchedEvent.getPath(), true));多次通知

  1. zk status:CONNECTING
  2. receive wathedEvent:WatchedEvent state:SyncConnected type:None path:null
  3. get child result:[]
  4. receive wathedEvent:WatchedEvent state:SyncConnected type:NodeChildrenChanged path:/zk_book
  5. ReGet child:[c1]
  6. receive wathedEvent:WatchedEvent state:SyncConnected type:NodeChildrenChanged path:/zk_book
  7. ReGet child:[c1, c2]

getChildren(异步)

  1. class ZkDemon4java implements Watcher {
  2. private static CountDownLatch countDownLatch = new CountDownLatch(1);
  3. private static ZooKeeper zooKeeper;
  4. public void process(WatchedEvent watchedEvent) {
  5. System.out.println("receive wathedEvent:" + watchedEvent);
  6. if (Event.KeeperState.SyncConnected == watchedEvent.getState()) {
  7. if (watchedEvent.getType() == Event.EventType.None && null == watchedEvent.getPath()) {
  8. countDownLatch.countDown();
  9. } else if (Event.EventType.NodeChildrenChanged == watchedEvent.getType()) {
  10. try {
  11. //if you need get advice again you must set watch:true
  12. System.out.println("ReGet child:" + zooKeeper.getChildren(watchedEvent.getPath(), true));
  13. } catch (KeeperException e) {
  14. e.printStackTrace();
  15. } catch (InterruptedException e) {
  16. e.printStackTrace();
  17. }
  18. }
  19. }
  20. }
  21. public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
  22. zooKeeper = new ZooKeeper("192.168.2.192:2181", 5000, new ZkDemon4java());
  23. System.out.println("zk status:" + zooKeeper.getState());
  24. countDownLatch.await();
  25. String path = "/zk_book";
  26. zooKeeper.create(path, "123".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
  27. //get children List and register Watch
  28. zooKeeper.getChildren(path, true, new IChildren2Callback(), "i am ctx");
  29. zooKeeper.create(path + "/c1", "123".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
  30. zooKeeper.create(path + "/c2", "123".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
  31. Thread.sleep(Integer.MAX_VALUE);
  32. }
  33. }
  34. class IChildren2Callback implements AsyncCallback.Children2Callback {
  35. public void processResult(int i, String s, Object o, List<String> list, Stat stat) {
  36. System.out.println("get children node result: result code:" + i + ",param path:" + s + ",ctx:" + o.toString() + ",children List:" + list + ",stat:" + stat);
  37. }
  38. }

结果:

  1. zk status:CONNECTING
  2. receive wathedEvent:WatchedEvent state:SyncConnected type:None path:null
  3. get children node result: result code:0,param path:/zk_book,ctx:i am ctx,children List:[],stat:211,211,1522231252330,1522231252330,0,0,0,0,3,0,211
  4. receive wathedEvent:WatchedEvent state:SyncConnected type:NodeChildrenChanged path:/zk_book
  5. ReGet child:[c1]
  6. receive wathedEvent:WatchedEvent state:SyncConnected type:NodeChildrenChanged path:/zk_book
  7. ReGet child:[c1, c2]

getData(同步)

  1. public class ZkDemon4java implements Watcher {
  2. private static CountDownLatch countDownLatch = new CountDownLatch(1);
  3. private static ZooKeeper zooKeeper;
  4. public void process(WatchedEvent watchedEvent) {
  5. System.out.println("receive wathedEvent:" + watchedEvent);
  6. try {
  7. if (Event.KeeperState.SyncConnected == watchedEvent.getState()) {
  8. if (watchedEvent.getType() == Event.EventType.None && null == watchedEvent.getPath()) {
  9. countDownLatch.countDown();
  10. } else if (Event.EventType.NodeDataChanged == watchedEvent.getType()) {
  11. System.out.println("ReGet Data:" + zooKeeper.getData(watchedEvent.getPath(), true, new Stat()));
  12. }
  13. }
  14. } catch (Exception e) {
  15. e.toString();
  16. }
  17. }
  18. public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
  19. zooKeeper = new ZooKeeper("192.168.2.192:2181", 5000, new ZkDemon4java());
  20. System.out.println("zk status:" + zooKeeper.getState());
  21. countDownLatch.await();
  22. String path = "/zk_book";
  23. System.out.println("get data result:" + zooKeeper.getData(path, true, new Stat()));
  24. zooKeeper.setData(path, "123".getBytes(), -1);
  25. zooKeeper.setData(path, "123".getBytes(), -1);
  26. Thread.sleep(Integer.MAX_VALUE);
  27. }
  28. }

结果:

  1. zk status:CONNECTING
  2. receive wathedEvent:WatchedEvent state:SyncConnected type:None path:null
  3. get data result:[B@73f792cf
  4. receive wathedEvent:WatchedEvent state:SyncConnected type:NodeDataChanged path:/zk_book
  5. ReGet Data:[B@20d91839
  6. receive wathedEvent:WatchedEvent state:SyncConnected type:NodeDataChanged path:/zk_book
  7. ReGet Data:[B@2e1ee252

getData(异步)

下面的api如果异步比较简单就都省略

setData

  1. package com.xh.zk.javaapi;
  2. import org.apache.zookeeper.*;
  3. import org.apache.zookeeper.data.Stat;
  4. import java.io.IOException;
  5. import java.util.concurrent.CountDownLatch;
  6. /**
  7. * Created by root on 3/28/18.
  8. */
  9. public class ZkDemon4java implements Watcher {
  10. private static CountDownLatch countDownLatch = new CountDownLatch(1);
  11. private static ZooKeeper zk;
  12. public void process(WatchedEvent watchedEvent) {
  13. if (Event.KeeperState.SyncConnected == watchedEvent.getState()) {
  14. if (Event.EventType.None == watchedEvent.getType() && watchedEvent.getPath() == null) {
  15. countDownLatch.countDown();
  16. }
  17. }
  18. }
  19. public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
  20. String connection = "192.168.2.192:2181";
  21. String path = "/zk_book";
  22. zk = new ZooKeeper(connection, 5000, new ZkDemon4java());
  23. countDownLatch.await();
  24. zk.create(path, "hello".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
  25. byte[] get_data = zk.getData(path, null, null);
  26. Stat set_stat = zk.setData(path, "456".getBytes(), -1);
  27. System.out.println(set_stat.getCzxid() + "," + set_stat.getMzxid() + "," + set_stat.getVersion());
  28. Stat set_stat2 = zk.setData(path, "qqq".getBytes(), set_stat.getVersion());
  29. System.out.println(set_stat2.getCzxid() + "," + set_stat2.getMzxid() + "," + set_stat2.getVersion());
  30. Stat set_stat3 = zk.setData(path, "aaa".getBytes(), set_stat.getVersion());
  31. System.out.println(set_stat3.getCzxid() + "," + set_stat3.getMzxid() + "," + set_stat3.getVersion());
  32. Thread.sleep(Integer.MAX_VALUE);
  33. }
  34. }

结果:

  1. 13,14,1
  2. 13,15,2
  3. Exception in thread "main" org.apache.zookeeper.KeeperException$BadVersionException: KeeperErrorCode = BadVersion for /zk_book

Version传入-1表示非原子操作,每次修改数据,版本号就递增,不一致就报错

exists

  1. package com.xh.zk.javaapi;
  2. import org.apache.zookeeper.*;
  3. import org.apache.zookeeper.data.Stat;
  4. import java.io.IOException;
  5. import java.util.concurrent.CountDownLatch;
  6. /**
  7. * Created by root on 3/28/18.
  8. */
  9. public class ZkDemon4java implements Watcher {
  10. private static CountDownLatch countDownLatch = new CountDownLatch(1);
  11. private static ZooKeeper zk;
  12. static String path = "/zk_book";
  13. public void process(WatchedEvent watchedEvent) {
  14. try {
  15. if (Event.KeeperState.SyncConnected == watchedEvent.getState()) {
  16. if (Event.EventType.None == watchedEvent.getType() && watchedEvent.getPath() == null) {
  17. countDownLatch.countDown();
  18. } else if (Event.EventType.NodeCreated == watchedEvent.getType()) {
  19. System.out.println(watchedEvent.getPath() + " NodeCreated");
  20. zk.exists(path, true);
  21. } else if (Event.EventType.NodeDataChanged == watchedEvent.getType()) {
  22. System.out.println(watchedEvent.getPath() + " NodeDataChanged");
  23. zk.exists(path, true);
  24. } else if (Event.EventType.NodeDeleted == watchedEvent.getType()) {
  25. System.out.println(watchedEvent.getPath() + " NodeDeleted");
  26. zk.exists(path, true);
  27. }
  28. }
  29. } catch (Exception e) {
  30. }
  31. }
  32. public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
  33. String connection = "192.168.2.192:2181";
  34. zk = new ZooKeeper(connection, 5000, new ZkDemon4java());
  35. countDownLatch.await();
  36. zk.exists(path, true);
  37. zk.create(path, "hello".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
  38. zk.create(path + "/abc", "abc".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
  39. zk.setData(path, "world".getBytes(), -1);
  40. zk.delete(path + "/abc", -1);
  41. zk.delete(path, -1);
  42. Thread.sleep(Integer.MAX_VALUE);
  43. }
  44. }

结果:

  1. /zk_book NodeCreated
  2. /zk_book NodeDataChanged
  3. /zk_book NodeDeleted

无论节点是否存在,都可用exists监听,对该节点增删改都会通知,但是不会通知其子节点的操作

addAuthInfo

创建一个需要权限访问的节点

  1. public class ZkDemon4java implements Watcher {
  2. private static CountDownLatch countDownLatch = new CountDownLatch(1);
  3. private static ZooKeeper zk_auth;
  4. static String path = "/zk_book";
  5. public void process(WatchedEvent watchedEvent) {
  6. }
  7. public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
  8. String connection = "192.168.2.192:2181";
  9. zk_auth = new ZooKeeper(connection, 5000, new ZkDemon4java());
  10. zk_auth.addAuthInfo("digest", "foo:true".getBytes());
  11. zk_auth.create(path, "hello".getBytes(), ZooDefs.Ids.CREATOR_ALL_ACL, CreateMode.EPHEMERAL);
  12. Thread.sleep(Integer.MAX_VALUE);
  13. }
  14. }

创建几个客户端访问之前的节点,分别是 :没有权限信息,错误权限信息,正确权限信息

  1. /**
  2. * no auth info
  3. */
  4. zk_1 = new ZooKeeper(connection, 5000, new Zk1());
  5. zk_1.getData(path, false, null);
  6. Thread.sleep(Integer.MAX_VALUE);

结果:

  1. Exception in thread "main" org.apache.zookeeper.KeeperException$NoAuthException: KeeperErrorCode = NoAuth for /zk_book
  1. /**
  2. * wrong auth info
  3. */
  4. zk_2 = new ZooKeeper(connection, 5000, new Zk2());
  5. zk_2.addAuthInfo("digest", "foo:true121".getBytes());
  6. zk_2.getData(path, false, null);
  7. Thread.sleep(Integer.MAX_VALUE);

结果:

  1. Exception in thread "main" org.apache.zookeeper.KeeperException$NoAuthException: KeeperErrorCode = NoAuth for /zk_book
  1. /**
  2. * right auth info
  3. */
  4. zk_3 = new ZooKeeper(connection, 5000, new Zk3());
  5. zk_3.addAuthInfo("digest", "foo:true".getBytes());
  6. byte[] zk_3Data = zk_3.getData(path, false, null);
  7. System.out.println(zk_3Data);
  8. Thread.sleep(Integer.MAX_VALUE);

结果:

  1. [B@37bba400

Zookeeper学习笔记3的更多相关文章

  1. ZooKeeper 学习笔记

    ZooKeeper学习笔记 1.   zookeeper基本概念 zookeeper是一个分布式的,开放源码的分布式应用程序协调服务,是hadoop和Habase的重要组件,是为分布式应用提供一致性服 ...

  2. ZooKeeper学习笔记(二)——内部原理

    zookeeper学习笔记(二)--内部原理 1. zookeeper的节点的类型 总的来说可以分为持久型和短暂型,主要区别如下: 持久:客户端与服务器端断开连接的以后,创建的节点不会被删除: 持久化 ...

  3. ZooKeeper学习笔记(一)——概述

    zookeeper学习笔记(一)--概述 1. 概述 Zookeeper是一个开源的分布式的,为分布式应用提供协调服务的Apache项目.zookeeper从设计模式的角度来理解:是一个基于观察者设计 ...

  4. Zookeeper学习笔记(中)

    Zookeeper学习笔记(中) Zookeeper的基本原理和基本实现 深入了解ZK的基本原理 ZK的一致性: ZAB 协议: Zookeeper 原子消息广播协议 ZK通过选举保证 leader ...

  5. Zookeeper学习笔记(上)

    Zookeeper学习笔记 本篇主要是一些基本的介绍和API的使用介绍, 有些只是记录了知识点,而没有完全在笔记中详细解释, 需要自行查找资料补充相关概念 主要参考了课程中的内容: Zookeeper ...

  6. ZooKeeper学习笔记一:集群搭建

    作者:Grey 原文地址:ZooKeeper学习笔记一:集群搭建 说明 单机版的zk安装和运行参考:https://zookeeper.apache.org/doc/r3.6.3/zookeeperS ...

  7. ZooKeeper学习笔记三:使用ZooKeeper实现一个简单的配置中心

    作者:Grey 原文地址:ZooKeeper学习笔记三:使用ZooKeeper实现一个简单的配置中心 前置知识 完成ZooKeeper集群搭建以及熟悉ZooKeeperAPI基本使用 需求 很多程序往 ...

  8. ZooKeeper学习笔记二:API基本使用

    Grey ZooKeeper学习笔记二:API基本使用 准备工作 搭建一个zk集群,参考ZooKeeper学习笔记一:集群搭建. 确保项目可以访问集群的每个节点 新建一个基于jdk1.8的maven项 ...

  9. ZooKeeper学习笔记四:使用ZooKeeper实现一个简单的分布式锁

    作者:Grey 原文地址: ZooKeeper学习笔记四:使用ZooKeeper实现一个简单的分布式锁 前置知识 完成ZooKeeper集群搭建以及熟悉ZooKeeperAPI基本使用 需求 当多个进 ...

  10. Zookeeper学习笔记(下)

    这是ZK学习笔记的下篇, 主要希望可以分享一些 ZK 的应用以及其应用原理 我本人的学习告一段落, 不过还遗留了一些ZK相关的任务开发和性能测试的任务, 留待以后完成之后再通过其他文章来进行分享了 Z ...

随机推荐

  1. 使用trash-cli防止rm -rf 误删除带来的灾难(“事前”非“事后”)

    trash-cli是一个使用 python 开发的软件包,包含 trash-put.restore-trash.trash-list.trash-empty.trash-rm等命令,我们可以通过这写命 ...

  2. SpringMVC简单项目配置

    一.首先,SpringMVC框架使用分层开发,分层是为了实现“高内聚,低耦合”.采用“分而治之”的思想,把问题划分开来各个解决,易于控制,延展和分配资源,最重要的是有利于后期项目维护.MVC是指Mod ...

  3. 2017-12-15python全栈9期第二天第三节之使用while循环输出0到10

    #!/user/bin/python# -*- coding:utf-8 -*-count = 0while count < 10: count += 1 print(count)

  4. css3好看的background渐变背景色积累

    1. Tippy.js background: linear-gradient(91deg,#f1eefc,#9dc6ff 70%,#a5bcff);(body背景色) background: lin ...

  5. 使用 boot-repair 对 Windows + Ubuntu 双系统引导修复

    问题描述:     由于在windows上进行更新/重装/修改了引导设置以后,windows会“自私”地重写引导,导致Ubuntu系统引导消失而无法选择Ubuntu启动.

  6. golang redis连接池使用方法

    package main import ( "fmt" "github.com/garyburd/redigo/redis" ) var pool *redis ...

  7. 伯克利SocketAPI(一) socket的C语言接口/最简单的服务器和对应的客户端C语言实现

    1. 头文件 2. API函数 3. 最简单的服务器和对应的客户端C语言实现 3.1 server #include <sys/types.h> #include <sys/sock ...

  8. windows server 禁用智能卡服务的步骤

    许多用户对于系统中的很多功能都不太了解,其中智能卡服务更是少有人知.智能卡服务就是对插入的智能卡进行管理和访问控制,大多数用户都无需使用此项功能.那么在Win7系统中要怎么取消智能卡服务呢? 1.首先 ...

  9. PhotoshopCC2018安装流程以及破解

    2018版增加了不少功能,也对优化PS软件进行了不少的优化,界面更加简洁美观 这里以64位为主. 1.首先下载好PhotoshopCC安装包和破解包,分别解压 2.解压完毕后,在安装包里面双击Setu ...

  10. 常见排序算法之python实现

    冒泡排序 简介 冒泡排序(英语:Bubble Sort)是一种简单的排序算法.它重复地遍历要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来.遍历数列的工作是重复地进行直到没有再需要交 ...