Python基本数据操作(1)字符/数字
来源:互联网 发布:巴比伦空中花园知乎 编辑:程序博客网 时间:2024/06/16 10:51
x = 3print(type(x)) # Prints "<type 'int'>"print(x) # Prints "3"print(x + 1 ) # Addition; prints "4"print(x - 1) # Subtraction; prints "2"print(x * 2 ) # Multiplication; prints "6"print(x ** 2) # Exponentiation; prints "9"x += 1print(x) # Prints "4"x *= 2print(x) # Prints "8"y = 2.5print(type(y) )print(y, y + 1, y * 2, y ** 2 )t = Truef = Falseprint (type(t)) # Prints "<type 'bool'>"print( t and f)# Logical AND; prints "False"print (t or f ) # Logical OR; prints "True"print (not t) # Logical NOT; prints "False"print (t != f ) # Logical XOR; prints "True" s = "hello"print (s.capitalize() ) # Capitalize a string; prints "Hello"print (s.upper() ) # Convert a string to uppercase; prints "HELLO"print (s.rjust(7) ) # Right-justify a string, padding with spaces; prints " hello"print (s.center(7) ) # Center a string, padding with spaces; prints " hello "print( s.replace('l', '(ell)') ) # Replace all instances of one substring with another; # prints "he(ell)(ell)o"print (' world '.strip() ) # Strip leading and trailing whitespace; prints "world"
阅读全文
1 0
- Python基本数据操作(1)字符/数字
- python基本数字类型操作实例
- python数据框基本操作
- Python基本数据操作(2)列表/字典
- [Python]python正则入门--基本元字符匹配操作
- <Python初学>基本数据str的操作
- <Python初学>基本数据list的操作
- Python数据分析库pandas基本操作
- python数据挖掘包Pandas基本操作
- python数据挖掘包numpy基本操作
- opencv-python基本操作(1)
- oracle基本操作-字符
- Python 基本字符
- 数字与字符的操作
- freemarker 数字,字符的操作
- Python 数字操作
- python 字符数字相互转化
- Python数字与字符转换
- Spring Boot (教程八: 过滤器、监听器、拦截器)
- forward
- 学c时的一个作业
- CI Weekly #22 | flow.ci 新版 iOS 构建流程的 4 大变化
- UVA 11426
- Python基本数据操作(1)字符/数字
- guidance问题总结
- Tensorlfow——变量
- 小仙女-快速入门javascript下下
- AOJ ALDS1_4_B《挑战程序设计竞赛2》
- web前端图片懒加载实现原理(二)
- tensorflow mnist实战笔记(二)制作和读取自己的数据集
- JAVA中常用IO流类:FileInputStream和FileOutputStream
- SVN图标详解