Python +字符串+列表+字典
2016-05-05 16:04
621 查看
应用1:
将字符串str,经过某字符如@、/、;,%,‘abc'等,用split()分割
之后变成列表List[]
然后,可以取列表中的一项,及多项
应用2:
字符串拼接:"user"+get["password"]
字符串比较:if user=="admin":
字符串应用:'ceph auth add %s'%(username)
应用3:Python 执行系统命令的方式
应用4:Python string 、int转换
1)int --> string
str是保留关键字,
a = 10
str1 = str(a)
2)string --> int
string a;1、type.parse.. float.Parse(a); Int32.Parse(a);2/Convert. Convert.ToInt32(a);3/强制显示转换 int b=(int)a;
应用5:判断一个对象为null?
python中没有null,有一个是None。如果只是判断为假,则可以
if not a:
如果是要判断是否为None,则:
if a is None:
附参考:
http://www.cr173.com/html/19245_1.html --------Python列表详解
将字符串str,经过某字符如@、/、;,%,‘abc'等,用split()分割
之后变成列表List[]
然后,可以取列表中的一项,及多项
应用2:
字符串拼接:"user"+get["password"]
字符串比较:if user=="admin":
字符串应用:'ceph auth add %s'%(username)
应用3:Python 执行系统命令的方式
应用4:Python string 、int转换
1)int --> string
str是保留关键字,
a = 10
str1 = str(a)
2)string --> int
string a;1、type.parse.. float.Parse(a); Int32.Parse(a);2/Convert. Convert.ToInt32(a);3/强制显示转换 int b=(int)a;
应用5:判断一个对象为null?
python中没有null,有一个是None。如果只是判断为假,则可以
if not a:
如果是要判断是否为None,则:
if a is None:
附参考:
http://www.cr173.com/html/19245_1.html --------Python列表详解
相关文章推荐
- Python3使用requests模块显示下载进度
- 在python下配置numpy,scipy
- vim升级7.4(启用python支持+遇到的错误)
- Python 32位 or 64位
- 中文字符乱码问题简单解决 python
- python使用mongo数据库
- UDPClient.py&UDPServer.py——我的第一行Python代码
- mininet python api
- Jupyter(IPython)
- 191. Number of 1 Bits [easy] (Python)
- PyCharm添加Python自定义模板
- 用Python制作简单的爬虫---爬虫基本思想
- 231. Power of Two [easy] (Python)
- python的学习笔记
- Python处理Excel(三):内置数据类型处理Excel数据
- python 中的赋值、引用、拷贝、作用域
- python第二站续--字典dict
- python代码结构
- python {File "<stdin>", line 1} error
- py2exe打包Python程序