Python3 基础语法 从入门到精通二
来源:互联网 发布:安装windows 2003灰色 编辑:程序博客网 时间:2024/06/03 18:20
#Python3 变量赋值i = 100; #整型变量d = 100.0; #浮点型s = "Python3"; #字符串print(i);print(d);print(s);#Python3 列表list = ['one','two','three','four','five'];print(list);print(list[0]);print(list[1:3]);print(list[2:]);print(list * 2);#Python3 元组arraylist = ('1','2','3','4','5');print(arraylist);print(arraylist[0]);print(arraylist[1:3]);print(arraylist[2:]);print(arraylist * 2);# Python3 字典dirt ={};dirt['one'] = 'one';dirt['two'] = 'two';dirt['thress'] = 'three';dirt['four'] = 'four';dirt['five'] = 'five';dirt[0] =0;dirt[1] =1;dirt[2] =2;dirt[3] =3;print(dirt['one']);print(dirt[0]);print(dirt);print(dirt.keys());print(dirt.values());#Python3 数据类型转换a = int('1');print("type is {0}".format(type(a))); #type 基础数据类型判断b = float(1);print("type is {0}".format(type(b))); #type 基础数据类型判断c = str(1);print("type is {0}".format(type(c))); #type 基础数据类型判断d = repr(1.0);print("type is {0}".format(type(d))); #type 基础数据类型判断#Python3 成员运算符e = 1;f = 6;lists = [1,2,3,4,5];def whether(a,b): if(a in b): return 'true'; else: return 'false';print("e is it inside {0}".format(whether(e,lists)));print("f is it inside {0}".format(whether(f,lists)));#Python3 身份运算符(基于对象)class Dog: def __init__(self,weight): self.weight = weight; def getWeight(self): print("my weight is {0}".format(self.weight));toady = Dog(10);boogie = Dog(15);if(toady is boogie): print("true");else: print("false");#Python3 身份运算符(基于数据类型)a = 10;b = 10;if(a is b): print("true");else: print("false");
0 0
- Python3 基础语法 从入门到精通二
- Python3 基础语法,从入门到精通一
- Python3基础语法 从入门到精通三
- Java从入门到精通_1 基础语法
- matlab从入门到精通(二)matlab语言基础
- spring security 从入门到精通二 基础配置
- Makefile语法详解 - 从入门到精通
- Python从入门到PY交易,基础语法,散记(二)
- RMS从入门到精通之二
- RMS从入门到精通之二
- Java学习从入门到精通(二)
- RMS从入门到精通之二
- VI - 从入门到精通之二
- RMS从入门到精通之二
- Servlet从入门到精通二
- Nginx开发从入门到精通二
- JMS&MQ,从入门到精通(二)
- ActiveMQ从入门到精通(二)
- [BZOJ3939][Usaco2015 Feb]Cow Hopscotch(cdq分治)
- java日志组件介绍(common-logging,log4j,slf4j,logback )
- HDU 3068 最长回文 (回文自动机)
- 数据结构—Problem B: 删除区间内的元素(线性表)
- Python3 基础语法,从入门到精通一
- Python3 基础语法 从入门到精通二
- Python3基础语法 从入门到精通三
- Codeforces 763B Timofey and rectangles(四色定理)(思维)
- C++之Set
- 数据结构(二)
- 290 Word Pattern
- java的匿名对象
- kill和kill -9
- 计算机组成原理【1】