Python实践二
来源:互联网 发布:windows桌面更新黑屏 编辑:程序博客网 时间:2024/06/03 14:06
#======================11======================类型转换python提供了一些方法对数值进行类型转换:int(x) #把x转换成整数float(x) #把x转换成浮点数str(x) #把x转换成字符串bool(x) #把x转换成bool值栗子:num = 18print 'My age is ' + str(num) # My age is 18print 'your age is '+ str(28) # your age is 28print 'your had money %.2f' %float(3.3) #your had money 3.30print 'your had money %.2f' %float('3.3') #your had money 3.30print 'your had money %s' %float('6.6666') #your had money 6.6666print 'your had money %d' %float('6.6666') #your had money 6print '%d' %int('123')# 123print '%d' %int(444.123) # 444print '%f' %int(444.123) # 444.000000print '%s' %int(444.123) # 444print '%d' %int(num) # 18print '%d' %bool(0) # 0print '%d' %bool(1) # 1print '%d' %bool('1') # 1print '%d' %bool('0') # 1print '%s' %bool(0) # Falseprint '%s' %bool(1) # Trueprint '%s' %bool('1') # Trueprint '%s' %bool('0') # Trueprint '%s' %bool('') # Falseprint '%s' %bool(' ') # True
0 0
- Python实践二
- python实践项目(二)
- python+django实践(二)
- selenium+Python+firefox动手实践二
- python数据分析实践(二)
- Python爬虫实践笔记(二)
- Python List 练习实践(二)
- Python Sting 练习实践(二)
- Python爬虫实践(二):Urllib库的简单使用
- Particle Filter 粒子滤波 原理以及python实践二
- python实践系列之(二)python爬取数据(上)
- 机器学习算法与Python实践之(二)支持向量机(SVM)初级
- 机器学习算法与Python实践之(二)k近邻(KNN)
- 机器学习算法与Python实践之(二)支持向量机(SVM)初
- 机器学习算法与Python实践之(二)k近邻(KNN)
- 机器学习算法与Python实践之(二)支持向量机(SVM)初级
- 机器学习算法与Python实践之(二)支持向量机(SVM)初级
- 机器学习算法与Python实践之(二)支持向量机(SVM)初级
- 程序学徒与导师
- Java内存模型和JVM优化总结
- 浅入rails。真的很浅
- 网站入侵工具 SQL注入神器
- Caffe
- Python实践二
- Regular Expression Matching
- SQL server 2008问题解决集锦
- 欢迎使用CSDN-markdown编辑器
- Python实践一
- iOS GPUImage研究七:动态相册初探(水印)
- 唯快不破:提升Web 应用的 13 个优化
- hdu1023(卡特兰数)
- sqlite错误 database disk image is malformed 可解决