题目: 最长公共前缀:编写一个函数来查找字符串数组中的最长公共前缀。 如果不存在公共前缀,返回空字符串 ""。 说明: 所有输入只包含小写字母 a-z 。 思路: 思路较简单。 程序: class Solution: def longestCommonPrefix(self, strs: List[ ...
分类:
编程语言 时间:
2020-05-06 23:14:22
阅读次数:
195
1.字符串拼接,join和列表的配合使用 a = '' d = ['d','h','t','dg','gh'] a = a.join(i for i in d) print(a) 运行结果: PS D:\Python\Code_Python\lintcode> & D:/python_install ...
分类:
编程语言 时间:
2020-05-06 09:14:44
阅读次数:
71
字符串操作 以下字符串可以 变量.函数() 也可以 "字符串".函数() capitalize() 首字母大写,其余转换为小写 print("test TEST".capitalize()) 输出 C:\Users\Administrator\AppData\Local\Programs\Pytho ...
分类:
编程语言 时间:
2020-05-01 20:44:13
阅读次数:
65
```python# 字符串串print(format('test', '20')) # 右对?齐print(format('test', '^20')) # 居中# 数值print(format(3, 'b')) # ?二进制print(format(97, 'c')) # 转换成unicode字... ...
分类:
其他好文 时间:
2020-05-01 01:34:31
阅读次数:
82
字符串相关: go实现python字符串的 .strip() 简单实现: package main import "fmt" func main() { s1 := " hello world 你好 世界 " for { if s1[0] != 32 && s1[len(s1)-1] !=32{ b ...
分类:
编程语言 时间:
2020-04-29 01:09:20
阅读次数:
93
Python 字符串 字符串是 Python 中最常用的数据类型。我们可以使用引号('或")来创建字符串。 创建字符串很简单,只要为变量分配一个值即可。例如: var1 = 'Hello World!' var2 = "Python Runoob" Python 访问字符串中的值 Python 不支 ...
分类:
编程语言 时间:
2020-04-27 21:04:28
阅读次数:
52
#!/usr/bin/python # -*- coding: UTF-8 -*- str = 'Hello World!' print str # 输出完整字符串 print str[0] # 输出字符串中的第一个字符 print str[2:5] # 输出字符串中第三个至第五个之间的字符串 pr ...
分类:
编程语言 时间:
2020-04-19 10:42:45
阅读次数:
65
LeetCode 1408. String Matching in an Array数组中的字符串匹配【Easy】【Python】【字符串】 Problem "LeetCode" Given an array of string . Return all strings in which is su ...
分类:
编程语言 时间:
2020-04-12 22:29:46
阅读次数:
94
变量 程序=数据结构+算法 变量就是可以重复使用的一个量,或者叫一个代号 变量命名的规则 变量命名可以包含数字,大小写字母,下划线或者更多,但是我们不推荐除了前三种内容之外的符号 数字不可以打头 4man, 5for 是不可以的 man4, for5是可以的 一般在python中,以下划线开头的内容 ...
分类:
编程语言 时间:
2020-04-10 12:04:35
阅读次数:
81
python字符串替换可以用两种方法实现: 1.用字符串本身的方法 2.用正则来替换字符串 下面用个例子来实验: a = 'hello word' 我把a字符串里的word替换为python 1.用字符串本身的replace方法 a.replace('word' , 'python') 输出结果是h ...
分类:
编程语言 时间:
2020-04-05 12:00:41
阅读次数:
108