package main; import ( "fmt" "strings" ) type person struct { name string; age int; } func main() { //判断是否包含某个子字符串 fmt.Println(strings.Contains("hello", "he")); //统计子符串的次数 fmt.Println(strings.Count("hello hello…
一.参考文章 1.C语言中getopt()和getopt_long()函数的用法 2.linux 中解析命令行参数 (getopt_long用法) 二.调试经验…
在Python编程语言中,enumerate()及zip()是两个常用的内置函数,这两个函数功能类似,但又有所区别,下面通过两个例子分别进行说明. enumerate()函数 该函数在字面上是枚举.列举的意思,用于将一个可遍历的数据对象(如列表.元组或字符串)组合为一个索引序列,同时列出数据和数据下标,一般用在 for 循环当中,可同时得到数据对象的值及对应的索引值.如对于下面的例子: 运行结果为: 注意:在enumerate()函数中,也可以给第2个参数“start”的值,指定当前索引的初始值…
1.malloc()和free()的基本介绍 (1)函数原型及说明 void *malloc(long NumBytes) 该函数分配了NumBytes个字节,并返回了指向这块内存的指针.如果分配失败,则返回一个空指针(NULL). void free(void *FirstByte) 该函数是将之前用malloc分配的空间还给程序或者是操作系统,也就是释放了这块内存,让它重新得到自由. (2)函数基本用法 char *Ptr = NULL; Ptr = ( * sizeof(char)); i…
strings包中的函数用法 参考链接http://studygolang.com/articles/88 1.strings.replace() 函数原型 func Replace(str1, old, str2, n int) string //old是str1中的字符串,用str2替换str1中的old,一共替换n个.如果n<0,则全部替换 fmt.Println(strings.Replace("tet tet tet", "e", "es&…
package _String_; import java.util.*; import java.math.*; import java.lang.*; public class _Strings { public static void main(String []args) { // 字符串构造 String str = new String("chd is cool!"); System.out.println(str); char a[] = {'g','o','o','d'…
模块简介 模块,用一砣代码实现了某个功能的代码集合. 类似于函数式编程和面向过程编程,函数式编程则完成一个功能,其他代码用来调用即可,提供了代码的重用性和代码间的耦合.而对于一个复杂的功能来,可能需要多个函数才能完成(函数又可以在不同的.py文件中),n个 .py 文件组成的代码集合就称为模块. 如:os 是系统相关的模块:file是文件操作相关的模块 模块分为三种:自定义模块.第三方模块.内置模块,下边简单介绍一些常用模块 #_*_coding:utf-8_*_ import time imp…
使用print函数的时候,可以像C一样格式化输出,同时还支持参数化输出 print('%s' % ("CooMark")) print('整数|%d|' % (123)) print('浮点数|%f|' % (123)) print('保留两位小数|%.2f|' % (123)) print('指定总宽度和小数位数|%8.2f|' % (123)) print('指定总宽度并且左对齐|%-8.2f|' % (123)) print('指定总宽度和用0占位|%08.2f|' % (123…
一.测试环境 Win10 + Visual Studio 2017 二.测试代码 #include "pch.h" #include <iostream> #include <string> #include <vector> using namespace std; int main(void) { ] = "hello"; ] = { 'h','e','l','l','o'}; char c[] = "hello&q…
最近在复习c语言的时候再次用到了malloc函数和free函数,此处着讲解一下自己对这两个函数的理解和认识. 一. malloc函数和free函数的基本概念和基本的用法 对于malloc函数: 1. 包含的头文件:<mallloc.h> 或者<stdlib.h> 2. 函数的原型:void *malloc(unsigned int NumBytes); 3. 函数功能: 该函数分配了NumBytes个字节的内存空间,如果成功,则返回指向这块内存的指针(即这块存储区域的首地址).如果…