码迷,mamicode.com
首页 >  
搜索关键字:python字符串    ( 1044个结果
Python 字符串
Python 字符串字符串是 Python 中最常用的数据类型。我们可以使用引号来创建字符串。创建字符串很简单,只要为变量分配一个值即可。例如:var1 = 'Hello World!' var2 = "Python Programming"Python访问字符串中的值Python不支持单字符类型,单字符也在Python也是作为一个字符串使用。Python访问子字符串,可以使用方括号来截取字符串,...
分类:编程语言   时间:2015-12-05 11:18:33    阅读次数:171
python学习之路之案例0(实现登录功能,登录错误次数超过3次,自动退出登录)
一、整个案例运用到的知识点1.python字典、字符串、列表的灵活转换和使用2.python数据结构之字符串:字符串的格式化、字符串的去空格(strip())3.python数据结构之字典:字典的构建、字典和字符串的转换4.python数据结构列表:列表的构建、列表和字符串的转换5.if....else......
分类:编程语言   时间:2015-12-03 15:43:30    阅读次数:441
python 字符串,数组,元祖操作基础巩固。
由于上个星期有点忙,没时间来抽空记一些有用的东西。丢了比较久的python很多忘记的小操作我也会重新捡起来以前最容易搞混的str.split()#操作会生成一个数组对象。example:'laplace'.split() #后面参数什么都没有加入,也会返回一个值['laplace']#如果后面加入分...
分类:编程语言   时间:2015-11-29 13:34:41    阅读次数:172
python字符串编码报错解决
写了一个简单的脚本,需要把中文目录名写入excel文件如果不做处理的话,程序会报错误"UnicodeDecodeError:‘ascii‘codeccan‘tdecodebyte0xb9inposition2:ordinal"这是因为ascii无法解码字符0xb9所以在字符串后面加上其解码所需的字符集,例如string.decode("gbk"),问题就解决了
分类:编程语言   时间:2015-11-13 19:23:58    阅读次数:265
Python 字符串操作
去空格及特殊符号s.strip().lstrip().rstrip(',')复制字符串#strcpy(sStr1,sStr2)sStr1 = 'strcpy'sStr2 = sStr1sStr1 = 'strcpy2'print sStr2连接字符串#strcat(sStr1,sStr2)sStr1...
分类:编程语言   时间:2015-11-06 14:25:56    阅读次数:190
Python 字符串格式化示例
先看代码吧。#!/usr/bin/env python#-*- coding: utf-8 -*-__author__ = 'jiang'__creattime__ = '2015/10/31 23:40'width = input('please enter width:')price_wid.....
分类:编程语言   时间:2015-11-01 10:13:44    阅读次数:266
Python字符串连接方式
python中有很多字符串连接方式,总结一下:1 最原始的字符串连接方式:str1 + str22 python 新字符串连接语法:str1, str23 奇怪的字符串方式:str1 str24 % 连接字符串:‘name:%s; sex: ’ % ('tom', 'male')5 字符串列表连接:...
分类:编程语言   时间:2015-10-29 11:12:43    阅读次数:162
python字符串
1
分类:编程语言   时间:2015-10-29 10:58:46    阅读次数:249
python 字符串反转
def reverse_str( s ): return s[::-1] def reverse_str( s ): t = '' for x in xrange(len(s)-1,-1,-1): t += s[x] return t
分类:编程语言   时间:2015-10-28 09:29:33    阅读次数:171
python 字符串列表的连接
strList = ["Python", "is", "good"] res = ' '.join(strList) #Python is good res = ''for s in strList: res += s + ' '#Python is good #最后还有个多余空格
分类:编程语言   时间:2015-10-28 09:24:31    阅读次数:192
1044条   上一页 1 ... 88 89 90 91 92 ... 105 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!