Python Numpy Tutorial: 基本数据类型
2017-05-07 23:11
591 查看
1.
python里面没有对变量“++”的操作,例如: “x++”
2.
用关键字“True”和“False”来表示bool特征,例如:
输出:
3.
python numpy里面没有“||”和“&&”符号,取而代之的为
输出为:
4.
输出:
强力支撑的string功能:注意的是在print语句里“%”是取地址符,然后取地址前不能随便加符号,空格即可
5.
输出:
python里面没有对变量“++”的操作,例如: “x++”
2.
用关键字“True”和“False”来表示bool特征,例如:
# -*- coding: utf-8 -*- """ Python Version: 3.5 Created on Sun May 7 22:27:34 2017 E-mail: Eric2014_Lv@sjtu.edu.cn @author: DidiLv """ import numpy as np t = True f = False print(type(t),type(f))
输出:
<class 'bool'> <class 'bool'>
3.
python numpy里面没有“||”和“&&”符号,取而代之的为
# -*- coding: utf-8 -*- """ Python Version: 3.5 Created on Sun May 7 22:27:34 2017 E-mail: Eric2014_Lv@sjtu.edu.cn @author: DidiLv """ import numpy as np t = True f = False # print(type(t),type(f)) print(t and f) print(t or f) print(t != f)
输出为:
False True True
4.
# -*- coding: utf-8 -*- """ Python Version: 3.5 Created on Sun May 7 22:38:38 2017 E-mail: Eric2014_Lv@sjtu.edu.cn @author: DidiLv """ hello = "hello" world = "world" print(hello) print(hello + " " + world) print(len(world)) hw12 = "%s %s %d" %(hello, world, 12) print(hw12) print("%s, %d" %(hello, 12))
输出:
hello hello world 5 hello world 12 hello, 12
强力支撑的string功能:注意的是在print语句里“%”是取地址符,然后取地址前不能随便加符号,空格即可
5.
# -*- coding: utf-8 -*- """ Python Version: 3.5 Created on Sun May 7 22:48:28 2017 E-mail: Eric2014_Lv@sjtu.edu.cn @author: DidiLv """ s = "hello" S = "HELLO" print(s.capitalize()) print(s.upper()) print(S.lower()) print(s.rjust(17)) print(len(s.rjust(17))) print(S.center(15)) print(S.replace("He", s)) # 注意看字符串中没有相应的替换字符时,输出原有字符串 print(S.replace("HE", s)) print(S.lower().rjust(20).strip()) #strip是删减的意思,这里是删减空格
输出:
Hello HELLO hello hello 17 HELLO HELLO helloLLO hello
相关文章推荐
- python -- numpy 基本数据类型,算术运算,组合,分割 函数
- 01Python的基本语法--数据类型
- Python 学习 (一) python的基本数据类型 元组 列表 字典
- 思维导图版Python3入门与进阶(一)基本数据类型
- Python基础02 基本数据类型
- python基础之几种基本数据类型
- python基本数据类型,数字与字符串
- 王亟亟的Python学习之路(三)-基础语法以及基本数据类型
- python中没有字符(char)这一基本数据类型
- python基本数据类型的功能介绍,每个数据类型都有自己的技能
- Python的基本数据类型
- Python快速学习02:基本数据类型 & 序列
- numpy中的基本数据类型
- Python基本数据类型
- [Python] - 基本数据类型和变量
- Python源码学习笔记(1 基本数据类型)
- 我的Python学习之路 Python的输入输出与基本数据类型
- Python入门之基本数据类型
- 4种编程语言基本数据类型及其取值范围整理(C++,Java,Python,Go)
- Python学习02:基本数据类型