码迷,mamicode.com
首页 >  
搜索关键字:python字符串    ( 1044个结果
Python-字符串相关面试题及答案
""" 1.1交换 已知 a的值为”hello”,b的值为”world”,如何交换a和b的值? 得到a的值为”world”,b的值为”hello” """ a = "hello" b = "world" a,b = b,a print(a) print(b) """ 1.2回文 回文的定义:”回文” ...
分类:编程语言   时间:2021-06-24 18:06:51    阅读次数:0
Python 字符串的匹配与替换
本文主要解析了 Python 中 re 模块的使用,进行字符串的匹配。分析了模块中各函数的功能作用与区别。 ...
分类:编程语言   时间:2021-06-02 10:59:15    阅读次数:0
python 字符串
str 用合理的方式转换为字符串 print(str("hello,\nworld!")) 'hello, world!' repr 用合法的python表达式表示 print(repr("hello,\nworld!"))'hello,\nworld!' 长字符串 要表示很长的字符串可以用三引号( ...
分类:编程语言   时间:2021-04-22 16:36:02    阅读次数:0
Python 学习教程
Python 简介 Python 入门教程 Python 编写代码语法 Python 注释作用写法及示例代码 Python 变量 Python 数据类型 Python 字符串(String)的使用 Python Number(数字)数值数据类型 Python 数据类型转换(Casting) Pyth ...
分类:编程语言   时间:2021-04-21 12:31:32    阅读次数:0
python字符串与列表的相互转化
字符串与列表的相互转化 字符转列表 str_ = 'sky' str_list = list(str_) print(str_list) # ['s', 'k', 'y'] 列表转字符 str_u = ''.join(str_list) print(str_u) # sky ...
分类:编程语言   时间:2021-04-16 11:42:44    阅读次数:0
Python字符串的查找
mystr = 'hello world and chris and java and python' #find(子串,开始位置,结束位置) 找不到返回-1 print(mystr.find('and')) print(mystr.find('and',15)) print(mystr.find( ...
分类:编程语言   时间:2021-03-09 13:15:53    阅读次数:0
python常用字符串功能
2.25 python字符串(13个) 1.以XX开头 (startswith()) v1="我爱我的祖国" result = v1.startswith("我") #判断是否以“我”开头,如果是返回"true" print(result) #true #例 v1=input("请输入户籍所在地") ...
分类:编程语言   时间:2021-02-27 13:13:22    阅读次数:0
Python字符串格式化
python字符串格式化 Python的字符串格式化有两种方式:%格式符方式,format方式 %格式符 %[(name)][flags][width].[precision]typecode (name) 可选,用于选择指定的key flags 可选,可供选择的值有: + 右对齐;正数前加正好,负 ...
分类:编程语言   时间:2021-02-17 14:51:45    阅读次数:0
python 字符串和字节串的转换
1、编码(encode) 字符串转字节串叫编码 str > bytes b = s.encode(encoding='utf-8') 2、解码(decode) 字节串转字符串叫解码 bytes > str s = b.decode(encoding='utf-8') ...
分类:编程语言   时间:2020-12-29 11:33:02    阅读次数:0
Python 字符串指定位置替换字符
指定位置替换字符 def replace_char(old_string, char, index): ''' 字符串按索引位置替换字符 ''' old_string = str(old_string) # 新的字符串 = 老字符串[:要替换的索引位置] + 替换成的目标字符 + 老字符串[要替换的 ...
分类:编程语言   时间:2020-12-25 12:09:20    阅读次数:0
1044条   1 2 3 4 ... 105 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!