当前位置: 首页 > 编程日记 > 正文

Linux命令之route - 显示和操作IP路由表

转自:  http://codingstandards.iteye.com/blog/1125312

用途说明

route命令用于显示和操作IP路由表(show / manipulate the IP routing table)。要实现两个不同的子网之间的通信,需要一台连接两个网络的路由器,或者同时位于两个网络的网关来实现。在Linux系统中,设置路由通常是 为了解决以下问题:该Linux系统在一个局域网中,局域网中有一个网关,能够让机器访问Internet,那么就需要将这台机器的IP地址设置为 Linux机器的默认路由。要注意的是,直接在命令行下执行route命令来添加路由,不会永久保存,当网卡重启或者机器重启之后,该路由就失效了;可以 在/etc/rc.local中添加route命令来保证该路由设置永久有效。本文中的例子中会验证这一点。

常用参数

格式:route

格式:/sbin/route

用于打印路由表(display the current routing table)。

在非root用户使用时需要使用完整路径执行route命令。

格式:route -n

格式:/sbin/route -n

用于打印路由表,加上-n参数就是在输出的信息中不打印主机名而直接打印ip地址。像netstat命令也有此参数。

格式:route add default gw {IP-ADDRESS} {INTERFACE-NAME}

用于设置默认路由(adds a default route, which will be used if no other route matches),其中,

参数{IP-ADDRESS): 用于指定路由器(网关)的IP地址(Specify router IP address);
参数{INTERFACE-NAME}: 用于指定接口名称,如eth0(Specify interface name such as eth0)。使用/sbin/ifconfig -a可以显示所有接口信息。

man route 写道
route add default gw mango-gw
adds a default route (which will be used if no other route matches). All packets using this route will
be gatewayed through "mango-gw". The device which will actually be used for that route depends on how we
can reach "mango-gw" - the static route to "mango-gw" will have to be set up before.

格式:route add -net {NETWORK-ADDRESS} netmask {NETMASK} dev {INTERFACE-NAME}

添加到指定网络的路由规则,其中

参数{NETWORK-ADDRESS}: 用于指定网络地址

参数{NETMASK}: 用于指定子网掩码

参数{INTERFACE-NAME}: 用于指定接口名称,如eth0。

man route 写道
route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0
adds a route to the network 192.56.76.x via "eth0". The Class C netmask modifier is not really necessary
here because 192.* is a Class C IP address. The word "dev" can be omitted here.

route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
This is an obscure one documented so people know how to do it. This sets all of the class D (multicast)
IP routes to go via "eth0". This is the correct normal configuration line with a multicasting kernel.

格式:route add -net {NETWORK-ADDRESS} netmask {NETMASK} reject

设置到指定网络为不可达,避免在连接到这个网络的地址时程序过长时间的等待,直接就知道该网络不可达。

man route 写道
route add -net 10.0.0.0 netmask 255.0.0.0 reject
This installs a rejecting route for the private network "10.x.x.x."

格式:route del -net {NETWORK-ADDRESS} netmask {NETMASK} dev {INTERFACE-NAME}

格式:route del -net {NETWORK-ADDRESS} netmask {NETMASK} reject

用于删除路由设置。参数指定的方式与route add相似。

route命令输出的路由表字段含义如下:

Destination 目标
              The destination network or destination host. 目标网络或目标主机。

       Gateway 网关
              The gateway address or '*' if none set. 网关地址,如果没有就显示星号。

       Genmask 网络掩码
              The  netmask  for  the  destination net; '255.255.255.255' for a
              host destination and '0.0.0.0' for the default route.

       Flags  Possible flags include 标志,常用的是U和G。
              U (route is up) 路由启用
              H (target is a host) 目标是主机
              G (use gateway) 使用网关
              R (reinstate route for dynamic routing)
              D (dynamically installed by daemon or redirect)
              M (modified from routing daemon or redirect)
              A (installed by addrconf)
              C (cache entry)
              !  (reject route)

       Metric 距离、跳数。暂无用。

The 'distance' to the target (usually counted in  hops).  It  is
              not  used  by  recent kernels, but may be needed by routing dae-
              mons.

       Ref   不用管,恒为0。

Number of references to this route. (Not used in the Linux  ker-
              nel.)

       Use    该路由被使用的次数,可以粗略估计通向指定网络地址的网络流量。

Count  of lookups for the route.  Depending on the use of -F and
              -C this will be either route cache misses (-F) or hits (-C).

       Iface 接口,即eth0,eth0等网络接口名

Interface to which packets for this route will be sent.

使用示例

示例一 打印当前路由表(root用户)

[root@jfht ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
211.103.28.0    *               255.255.255.224 U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 eth1
169.254.0.0     *               255.255.0.0     U     0      0        0 eth1
default         211.103.28.1    0.0.0.0         UG    0      0        0 eth0
[root@jfht ~]# /sbin/route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
211.103.28.0    *               255.255.255.224 U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 eth1
169.254.0.0     *               255.255.0.0     U     0      0        0 eth1
default         211.103.28.1    0.0.0.0         UG    0      0        0 eth0
[root@jfht ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
211.103.28.0    0.0.0.0         255.255.255.224 U     0      0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth1
0.0.0.0         211.103.28.1    0.0.0.0         UG    0      0        0 eth0
[root@jfht ~]# /sbin/route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
211.103.28.0    0.0.0.0         255.255.255.224 U     0      0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth1
0.0.0.0         211.103.28.1    0.0.0.0         UG    0      0        0 eth0
[root@jfht ~]#

示例二 打印当前路由表(非root用户)

[web@hnweb1 ~]$ route
-bash: route: command not found
[web@hnweb1 ~]$ /sbin/route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.66.10.0      *               255.255.255.128 U     0      0        0 eth0
192.130.12.0    10.66.10.1      255.255.255.0   UG    0      0        0 eth0
10.0.0.0        *               255.255.255.0   U     0      0        0 eth1
10.66.0.0       10.66.10.1      255.255.0.0     UG    0      0        0 eth0
134.161.0.0     10.66.10.1      255.255.0.0     UG    0      0        0 eth0
10.20.0.0       10.66.10.1      255.255.0.0     UG    0      0        0 eth0
169.254.0.0     *               255.255.0.0     U     0      0        0 eth1
172.224.0.0     10.66.10.1      255.255.0.0     UG    0      0        0 eth0
default         10.66.10.22     0.0.0.0         UG    0      0        0 eth0
[web@hnweb1 ~]$ route -n
-bash: route: command not found
[web@hnweb1 ~]$ /sbin/route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.66.10.0      0.0.0.0         255.255.255.128 U     0      0        0 eth0
192.130.12.0    10.66.10.1      255.255.255.0   UG    0      0        0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U     0      0        0 eth1
10.66.0.0       10.66.10.1      255.255.0.0     UG    0      0        0 eth0
134.161.0.0     10.66.10.1      255.255.0.0     UG    0      0        0 eth0
10.20.0.0       10.66.10.1      255.255.0.0     UG    0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth1
172.224.0.0     10.66.10.1      255.255.0.0     UG    0      0        0 eth0
0.0.0.0         10.66.10.22     0.0.0.0         UG    0      0        0 eth0
[web@hnweb1 ~]$

示例三 设置到某网络的路由的例子

下面的例子 来自一个实际的服务器配置。 route命令写在了/etc/rc.local中,这样就设置了一条永久路由。

[root@jf07 root]# grep route /etc/rc.local
route add -net 10.0.0.0/8 gw 10.33.149.1 dev eth1
[root@jf07 root]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.32.181.182   10.33.149.1     255.255.255.255 UGH   0      0        0 eth1
10.33.136.135   10.33.149.1     255.255.255.255 UGH   0      0        0 eth1
10.32.208.13    10.33.149.1     255.255.255.255 UGH   0      0        0 eth1
10.33.149.0     *               255.255.255.128 U     0      0        0 eth1
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0
169.254.0.0     *               255.255.0.0     U     0      0        0 eth1
10.0.0.0        10.33.149.1     255.0.0.0       UG    0      0        0 eth1
default         192.168.1.254   0.0.0.0         UG    0      0        0 eth0
[root@jf07 root]#

示例四 添加拒绝路由的测试

[root@jfht ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
211.103.28.0    *               255.255.255.224 U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 eth1
169.254.0.0     *               255.255.0.0     U     0      0        0 eth1
default         211.103.28.1    0.0.0.0         UG    0      0        0 eth0
[root@jfht ~]# ping 10.33.11.12
PING 10.33.11.12 (10.33.11.12) 56(84) bytes of data.
Ctrl+C
--- 10.33.11.12 ping statistics ---
21 packets transmitted, 0 received, 100% packet loss, time 19999ms

[root@jfht ~]# route add -net 10.0.0.0 netmask 255.0.0.0 reject
[root@jfht ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
211.103.28.0    *               255.255.255.224 U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 eth1
169.254.0.0     *               255.255.0.0     U     0      0        0 eth1
10.0.0.0        -               255.0.0.0       !     0      -        0 -
default         211.103.28.1    0.0.0.0         UG    0      0        0 eth0
[root@jfht ~]# ping 10.33.11.12                                
connect: Network is unreachable
[root@jfht ~]#

示例五 设置路由之后重启机器的测试

[root@node34 root]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.227.0   *               255.255.255.0   U     0      0        0 eth0
169.254.0.0     *               255.255.0.0     U     0      0        0 eth0
default         192.168.227.2   0.0.0.0         UG    0      0        0 eth0
[root@node34 root]# route add -net 10.0.0.0 netmask 255.0.0.0 reject
[root@node34 root]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.227.0   *               255.255.255.0   U     0      0        0 eth0
169.254.0.0     *               255.255.0.0     U     0      0        0 eth0
10.0.0.0        -               255.0.0.0       !     0      -        0 -
default         192.168.227.2   0.0.0.0         UG    0      0        0 eth0
[root@node34 root]# reboot

Broadcast message from root (pts/0) (Thu Jul  7 05:31:26 2011):

The system is going down for reboot NOW!
[root@node34 root]#

Last login: Thu Jul  7 05:30:50 2011 from 192.168.227.1
[root@node34 root]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.227.0   *               255.255.255.0   U     0      0        0 eth0
169.254.0.0     *               255.255.0.0     U     0      0        0 eth0
default         192.168.227.2   0.0.0.0         UG    0      0        0 eth0
[root@node34 root]#

上面的测试表明route设置的路由在机器重启之后就消失了。

示例六 将route命令添加到/etc/rc.local来设置永久路由的测试

先用vi在/etc/rc.local后面添加route命令。

[root@node34 root]# tail /etc/rc.local
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

# 2011.07.15 add permanent route test
route add -net 10.0.0.0 netmask 255.0.0.0 reject


[root@node34 root]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.227.0   *               255.255.255.0   U     0      0        0 eth0
169.254.0.0     *               255.255.0.0     U     0      0        0 eth0
default         192.168.227.2   0.0.0.0         UG    0      0        0 eth0
[root@node34 root]# reboot

Broadcast message from root (pts/0) (Fri Jul 15 14:43:44 2011):

The system is going down for reboot NOW!
[root@node34 root]#


Last login: Fri Jul 15 14:40:22 2011 from 192.168.227.1
[root@node34 root]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.227.0   *               255.255.255.0   U     0      0        0 eth0
169.254.0.0     *               255.255.0.0     U     0      0        0 eth0
10.0.0.0        -               255.0.0.0       !     0      -        0 -
default         192.168.227.2   0.0.0.0         UG    0      0        0 eth0
[root@node34 root]#

示例七 删除路由的测试

删除路由的时候只需将route add改成route del,其他参数类似。如果报“无效的参数”或“没有那个进程”,可能是因为提供的参数不够。

[root@node34 root]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.227.0   *               255.255.255.0   U     0      0        0 eth0
169.254.0.0     *               255.255.0.0     U     0      0        0 eth0
10.0.0.0        -               255.0.0.0       !     0      -        0 -
default         192.168.227.2   0.0.0.0         UG    0      0        0 eth0
[root@node34 root]#
[root@node34 root]# route del -net 10.0.0.0
SIOCDELRT: 无效的参数
[root@node34 root]# route del -net 10.0.0.0 netmask 255.0.0.0
SIOCDELRT: 没有那个进程
[root@node34 root]#
[root@node34 root]# route del -net 10.0.0.0 netmask 255.0.0.0 reject
[root@node34 root]#

[root@node34 root]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.227.0   *               255.255.255.0   U     0      0        0 eth0
169.254.0.0     *               255.255.0.0     U     0      0        0 eth0
default         192.168.227.2   0.0.0.0         UG    0      0        0 eth0
[root@node34 root]#

问题思考

相关资料

【1】nixCraft Linux setup default gateway with route command
http://www.cyberciti.biz/faq/linux-setup-default-gateway-with-route-command/

【2】360doc Linux route命令
http://www.360doc.com/content/11/0418/14/2054285_110501874.shtml

【3】Linux公社 Linux下route add route del 用法
http://www.linuxidc.com/Linux/2010-11/30032.htm

【4】鳥哥的 Linux 私房菜 第五章、 Linux 常用網路指令

http://linux.vbird.org/linux_server/0140networkcommand.php#route

转载于:https://www.cnblogs.com/kittychentao2013/p/3216405.html

相关文章:

ActivityRouter 框架简单实用

ActivityRouter组件化开发小助手用法如下: 跟目录build.gradle dependencies {// activityRouterclasspath com.neenbedankt.gradle.plugins:android-apt:1.8}allprojects {repositories {// ActivityRoutermaven { url "https://jitpack.io" }} } module…

C++ 互斥锁和条件变量实现读写锁

最近的诸多面试经历确实让自己发现内功还不够&#xff0c;还需要持续的学习精进。 实现如下&#xff1a; class RWLock{private:int state;mutex mu;condition_variable cond;public:RWLock():state(0){}void rlock(){mu.lock();while(state < 0){cond.wait(mu);}state;mu…

经常用得到的安卓数据库基类

//创建数据库 public class DBCreate { public static void CreateDatabase(SQLiteDatabase db) { db.beginTransaction(); try { create_NetTaskBuffer(db); insert_SQL(db); db.setTransactionSuccessfu…

mysql5.7 zip安装配置_MySQL5.7的.zip文件的配置安装

由于MySQL5.7之后在javaEE中交互的端口发生了变化&#xff0c;而MySQL官网中5.6、5.7版本64位的只有.zip文件&#xff0c;而.zip文件不像直接下载installer一样可以获取到初始密码&#xff0c;需要通过管理员身份输入命令skip初始密码&#xff0c;所以记录.zip下安装配置过程。…

Linux vsftp配置详解

一.vsftpd说明:LINUX下实现FTP服务的软件很多,最常见的有vsftpd,Wu-ftpd和Proftp等.Red HatEnterprise Linux中默认安装的是vsftpd.访问FTP服务器时需要经过验证,只有经过了FTP服务器的相关验证,用户才能访问和传输文件.vsftpd提供了3种ftp登录形式:(1)anonymous(匿名帐号)使用…

top命令详解-性能分析

top命令是Linux下常用的性能分析工具&#xff0c;能够实时显示系统中各个进程的资源占用状况&#xff0c;常用于服务端性能分析。 top命令说明 [www.linuxidc.comlinuxidc-t-tomcat-188-193 ~]$ top top - 16:07:37 up 241 days, 20:11, 1 user, load average: 0.96, 1.13, 1.2…

leetcode-53 最大子序和

题目描述如下&#xff1a; 给定一个整数数组 nums &#xff0c;找到一个具有最大和的连续子数组&#xff08;子数组最少包含一个元素&#xff09;&#xff0c;返回其最大和。 示例: 输入: [-2,1,-3,4,-1,2,1,-5,4], 输出: 6 解释: 连续子数组 [4,-1,2,1] 的和最大&#xff0c;…

docker 离线安装 mysql_Oracle数据库之docker 离线环境安装oracle

本文主要向大家介绍了Oracle数据库之docker 离线环境安装oracle&#xff0c;通过具体的内容向大家展现&#xff0c;希望对大家学习Oracle数据库有所帮助。因测试需要&#xff0c;需在内网的测试环境搭建一套docker Oracle 11g环境进行测试&#xff0c;测试环境为redhat 6.6 安装…

ios Develop mark

App Distribution Guidehttps://developer.apple.com/library/ios/documaentation/IDEs/Conceptual/AppDistributionGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40012582 马上着手开发 iOS 应用程序 (Start Developing iOS Apps Today)https://developer.app…

联想打字必须按FN+数字-fn打字

对于联想G40、14英寸系列的本本&#xff0c;好多时候无意间可能把数字键锁定了。 这时候要做的是&#xff1a;打开运行--输入OSK--打开虚拟屏幕键盘。这时候可以找到 选项---打开数字键盘。 有时候某些电脑上没有NUMLOCK这个键。当小键盘打开的时候就又numlock这个键了。这时候…

每日记载内容总结50

Maven中的dependencyManagement 意义【原文链接】 在Maven中dependencyManagement的作用其实相当于一个对所依赖jar包进行版本管理的管理器。 pom.xml文件中&#xff0c;jar的版本判断的两种途径&#xff1a; (1)&#xff1a;如果dependencies里的dependency自己没有声明versio…

leetcode-152 乘积最大子序列

题目描述&#xff1a; 给定一个整数数组 nums &#xff0c;找出一个序列中乘积最大的连续子序列&#xff08;该序列至少包含一个数&#xff09;。 示例 1: 输入: [2,3,-2,4] 输出: 6 解释: 子数组 [2,3] 有最大乘积 6。 示例 2: 输入: [-2,0,-1] 输出: 0 解释: 结果不能为…

js 监听 安卓事件_百行代码实现js事件监听实现跨页面数据传输

百行代码实现js事件监听实现跨页面数据传输使用场景类似消息队列的使用场景,支持同页面和跨页面通信,发送消息和接收消息技术原理跨页面通信:基于事件监听,通过监听 storage事件监听回调机制,实现跨页面通信,让每个只操作自身页面的操作同页面事件监听:发送事件时,查找回调函数…

Centos安装GD库

tar zxvf ncurses-5.6.tar.gz 进入目录 cd ncurses-5.6 生成 makefile文件&#xff0c;再进一步编译 ./configure --prefix/usr --with-shared --without-debug 编译&#xff0c;编译时间稍微长些&#xff0c;稍等make 编译好最后就是安装了 make install 下面才开始安装 GD库…

centos7安装mongodb3.4

先下载安装包&#xff0c;OS选择RHEL 7.0 Linux 64-bit x64&#xff0c;package选择Server。 这里OS选6.2应该也行&#xff0c;没试过&#xff0c;如果linux版本是6.*的话注意选这个&#xff0c;如果选择7.0安装的时候会提示缺少glibc依赖&#xff08;glibc版本过低&#xff09…

leetcode-300 最长上升子序列

题目描述&#xff1a; 给定一个无序的整数数组&#xff0c;找到其中最长上升子序列的长度。 示例: 输入: [10,9,2,5,3,7,101,18] 输出: 4 解释: 最长的上升子序列是 [2,3,7,101]&#xff0c;它的长度是 4。 说明: 可能会有多种最长上升子序列的组合&#xff0c;你只需要输出对…

转载自——Json.net动态序列化以及对时间格式的处理

关于我工作中对Json处理的东西 第一:动态序列化类 第二:时间格式处理 通常我们一个类里 可能有十到更多的属性,但是我们序列化通常只需要序列化其中的 三到五个这样的话就会有多余的数据 如果 我只想序列化 id 跟name如何处理 这是我找的网上的方法: using Newtonsoft.Json…

congratulation的用法_congratulation的用法

congratulation用作名词&#xff0c;表示祝贺&#xff0c;恭喜&#xff1b;congratulation表示抽象意义的“祝贺”时&#xff0c;为不可数名词。表示祝贺词时&#xff0c;用作可数名词。1.表示抽象意义的“祝贺”时&#xff0c;为不可数名词。I sent her a gift as a token of …

腾讯微博API时间线相关接口返回的微博信息中head值使用问题

腾讯微博API时间线相关接口返回的微博信息中head值表示作者头像url&#xff0c;这个链接直接访问并不能使用&#xff0c;需要再附加一个参数指定图片的大小&#xff08;100、50&#xff09;&#xff0c;比如&#xff1a;[head]/100。

java实现https请求

参考&#xff1a; https://www.cnblogs.com/chinway/p/5802541.html java 实现https请求 JSSE是一个SSL和TLS的纯Java实现&#xff0c;通过JSSE可以很容易地编程实现对HTTPS站点的访问。但是&#xff0c;如果该站点的证书未经权威机构的验证&#xff0c;JSSE将拒绝信任该证书从…

设计模式 之美 --- 初篇

接下来的一段时间将按照如下体系导图&#xff0c;对23种设计模式 按照自己的理解一一总结&#xff0c;为后续工作中持续灵活使用做好积累。 学习应用 设计模式的过程有如下好处 提高复杂代码的设计开发能力让阅读源码 和 学习框架事半功倍告别被别人吐槽的烂代码为职场发展做…

C语言中将0到1000的浮点数用强制指针类型转换的方式生成一幅图像

搞过计算机图像的人都知道&#xff0c;图像中的每一个像素通常为一个整型数&#xff0c;它可以分成4个无符号的char类型&#xff0c;以表示其RGBA四个分量。一幅图像可以看做是一个二维整型数组。这里我会生成一个float数组&#xff0c;其数组大小为1000000&#xff0c;刚好100…

mysql用户控制登录_MySql用户权限控制_MySQL

bitsCN.comMySql用户权限控制本文将介绍&#xff2d;ySql创建帐号&#xff0c;删除帐号&#xff0c;设置和介绍各种帐号的权限创建用户帐号&#xff1a; www.bitsCN.com[sql]CREATE USER user_name IDENTIFIED BY your_password;改名[sql]RENAME USER old_name TO new_name;删除…

[python] 从GPS坐标获取国家名

目标比较明确&#xff0c;就是从GPS坐标得到它所在的国家。网上可以找的比较典型的解决方案是利用一些网站&#xff08;例如Google&#xff09;的webservice来完成这个任务&#xff0c;但是这些解决方案有一个比较大的弱点&#xff0c;就是这些webservice会限制请求的次数&…

Djiango模板语言DTL

一、变量 def dtl(request):num 3.14ss abc123嘿嘿# return render(request, django_dtl.html, {number: num, ss: ss})result Truelist [1, 2, 3, 4, 5]dic {name: owen, age: 28}# 函数不能带有参数&#xff0c;模板中{{ fn }} 本质就是调用函数拿到函数值&#xff08;函…

设计模式 之美 -- 面向对象(C/C++分别实现)

文章目录前言封装C实现C 实现继承C 实现C实现前言 为了保证代码的可复用性、可扩展性、可维护性&#xff0c;我们提出了面向对象的思想。 面向对象的核心特性有以下几个 封装特性 信息隐藏或者数据访问保护。类通过暴露有限的访问接口&#xff0c;授权外部仅能通过类提供的方…

数据结构编程实战汇总

出自数据结构与算法分析第二版&#xff08;C&#xff09; 一 引论二 算法分析三 表 栈 队列四 树五 散列六 优先队列七 排序 优先队列实现事件模拟 &#xff1a;http://maozj.iteye.com/blog/676567d堆 左式堆 斜堆&#xff1a; http://blog.csdn.net/yangtrees/article/detai…

同时支持三个mysql+sqlite+pdo的php数据库类_同时支持三个MySQL+SQLite+PDO的PHP数据库类...

PHP学习教程文章简介&#xff1a; 同时支持三个MySQLSQLitePDO的PHP数据库类使用方法: // mysql connect $db new SQL(mysql:hostlocalhost;database21andy_blog;, 21andy.com_user, 21andy.com_password); // PDO SQLite3 connect $db new SQL(pdo:database/21andy.com/21an…

VB6基本数据库应用(五):数据的查找与筛选

同系列的第五篇&#xff0c;上一篇在&#xff1a;http://blog.csdn.net/jiluoxingren/article/details/9633139 数据的查找与筛选 第4篇发布到现在已经过了4天&#xff0c;很抱歉&#xff0c;学生党&#xff0c;还是悲催的高三&#xff0c;没办法&#xff0c;8月1就开学了。以后…

学习进度条(第一周)

学习进度条&#xff1a; 第一周 所花时间&#xff08;包括上课&#xff09; 5h 代码量&#xff08;行&#xff09; 150 博客量&#xff08;篇&#xff09; 2 了解到的知识点 这种主要是对上学期web知识的一个回顾&#xff0c;进行了第一次开学测验&#xff0c;了解了实…