现在位置: 首页 > 编程语言 > 文章
2018年10月06日 编程语言 ⁄ 共 798字 评论关闭
一、自定义函数 1.1 代码 文件:abc.py #!/usr/bin/env python def add(x=4): return x+x print add() print add(3.6) print add("hello") 1.2 输出结果 二、md5加密、base64加密/解密 2.1 hashlib简介 hashlib是个专门提供哈希算法的库,现在里面包括md5、sha1、sha224、sha256、sha384、sha512,使用非常简单、方便你。 md5经常用来做用户密码的存储。 sha1经常用来作数字签名。 2.2 代码 文件:test.py #!/us...
阅读全文
一、变量定义/注释 1.1 变量定义同C语言          字母、数字、下划线          字母或下划线开始          区分大小写         name = "Tom" 1.2 注释         #         “”:一种特别的注释,在模块、类或函数的起始添加一个字符串 二、数据类型 2.1 python对象         身份:该对象的内存地址。 通过id()来得到。         类型:该对象的值类型。通过type()来得到。         值: 2.2 类型         数字  ( 整型、长整型...
阅读全文
一、HTTP协议介绍 1.1 HTTP协议是一种无状态协议       同一客户端的这次请求和上次请求没有对应关系。 1.2 HTTP协议在TCP/IP协议栈中的位置       HTTP承载于TCP协议之上。             端口:80       HTTPS承载于TLS/SSL协议之上。  端口:443 1.3 HTTP的请求响应模型       HTTP永远是客户端发起请求,服务器响应。       无法实现客户端没发起请求的时候,服务器将消息推送给客户端。 二、HTTP请求消息 2.1 请求消息格...
阅读全文
2018年10月06日 编程语言 ⁄ 共 583字 评论关闭
使用Source Insight查看D:\Code\fast_hjdns\trunk\src目录下的C/C++源代码。 一、使用Source Insight创建Project1. 打开Source Insight 2. Project --> New Project      输入New project name:fast_hjdns。      选择路径:D:\SourceInsightProject。3. OK 二、设置源代码目录      在"Project Source Directory - the main location of your source files:"中:选择目录D:\Code\fast_hjdns\trunk\src。4. OK 三、添加源...
阅读全文
2018年10月05日 编程语言 ⁄ 共 740字 评论关闭
zlib简单示例代码,compress、uncompress: #include <iostream> #include <string> #include <zlib.h> #include <zconf.h> using namespace std; int main(int argc, char *argv[]) { // unsigned char szSrc[] = "test the compression and uncompression of zlib."; unsigned long nSrcLen = sizeof(szSrc); unsigned char szZip[1024] = {0}; unsigned long nZipLen = 1024; compres...
阅读全文
2018年10月05日 编程语言 ⁄ 共 1629字 评论关闭
打开关闭函数:gzopen、gzclose 写gzip file函数:gzwrite、gzputs、gzputc、gzprintf 读gzip file函数:gzread、gzgets、gzgetc 其他函数:gztell、gzseek、gzrewind 两个不太好理解的函数:gzungetc、gzoffset 代码如下: #include <iostream> #include <string> #include <zlib.h> #include <zconf.h> using namespace std; void main(int argc, char *argv[]) { //ab每次写的时候追加,wb...
阅读全文
获取版本函数:zlibVersion        压缩函数:deflateInit、deflate、deflateEnd   解压缩函数:inflateInit、inflate、inflateEnd #include <iostream> #include <string> #include <zlib.h> #include <zconf.h> using namespace std; #define CHUNK 16384 int def(FILE *source, FILE *dest, int level) { z_stream strm; strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NU...
阅读全文
2018年10月05日 编程语言 ⁄ 共 4550字 评论关闭
ma_dir_op.h: //////////////////////////////////////////////////////////////// // //Descript: directory operation class // Author: guowenyan // Date: 2013.06.13 // //////////////////////////////////////////////////////////////// #pragma once #include <string> #include <vector> class CMaDirOperation { public: static CMaDirOperation *get_instance(); public: bool traverse_pa...
阅读全文
2018年10月05日 编程语言 ⁄ 共 2990字 评论关闭
一、命令行解析 tprogram_options解析命令行参数示例代码: #include <iostream> using namespace std; #include <boost/program_options.hpp> namespace po = boost::program_options; int main(int argc, char*argv[]) { //int level; po::options_description desc("Allowed options"); desc.add_options() ("help", "produce help message") //("help,h", "produce help message") ("compression"...
阅读全文
2018年10月04日 编程语言 ⁄ 共 1166字 评论关闭
    #include <stdio.h> #include <tchar.h> #include <malloc.h> int g_i = 100; int g_j = 200; int g_k,g_h; void main(int argc,TCHAR*argv[]) { const int MAXN = 100; int *p = (int*)malloc(MAXN * sizeof(int)); static int s_i = 10; static int s_j = 20; static int s_k; static int s_h; int i = 10; int j = 20; int k = 40; int f,h; char *pstr1 = ...
阅读全文