python 入门学习笔记之基本语法与基本数据类型
来源:互联网 发布:全网比价软件 编辑:程序博客网 时间:2024/04/29 03:58
1.在python中有3种基本数据类型interage,floats,booleans;
2.声明变量为 varible =1
3.python是一种区分大小写的语言
4.基本运算符
+ ,-,*,**(幂运算),/ (除),%(取模)
5.函数实现
def Function():
....
return ...
函数以缩进分段。
6.python 行注释为 #this is comment
7.Python 多行注释为
“”
This is a comment for python
“”
8.type()函数返回变量类型
9.python 中的string
用’’或者” “包成
如 var_str=”Sherlock”
取第一个字符可直接 var_firstletter= var_str[0]
或者 var_firstletter=”Sherlock”[1]
\来实现转义字符
字符串基本函数
lower() 转换为小写
upper()转换为大写
如:
print(len(var_str),var_str.lower(),var_str.upper())
len(object) 求string长度
str() 将数字转换成字符串
str[0:n]方法得到自字符串
str[n:]得到n+1后的子字符串
.
print()打印函数
python六种比较方法==,!=,<,>,<=,>=
逻辑连接词 and ,or , not
if 语句格式
if condition:
Statement
if else 语句格式
if condition:
Statement
....
else :
Statement
....
Else if语句格式
if condition:
Statement
....
elif condition:
Statement
...
row_input实现输入
name=row_input(“attention statement”)
isalpha()判断是否为数字
import 导入模块和函数,类似c的include
from module import function
from module import *
list 普通链表的使用,可以动态增减
lst=[元素] 声明为list类型,内容为空
lst=[“name”,”year”] 则lst[0]的值为name
index(item)方法返回item在list中的下标
insert(index,item)方法在index插入item
sort()方法排序,默认从小到大
remove(item)
Tuple 固定数组,定义后元素个数不能改变
定义方式arr=(元素)
python 中的字典
dictionary={}空字典
在字典里添加或者更改一个key的value 格式为
dictionary[key]=value
删除del dictionary[key]
key 可对应一个列表
dictionary={key:[]}
用dictionary[key][index]进行调用
- python 入门学习笔记之基本语法与基本数据类型
- Python的入门与进阶的学习笔记之Python基本数据类型
- Python语法 之 基本数据类型
- python学习笔记之-基本数据类型
- Python学习笔记之基本数据类型
- Python语言学习笔记之基本语法
- Python入门之基本数据类型
- python 学习笔记----基本语法
- Python学习笔记-基本语法
- 《python入门学习笔记1》(基本数据类型)
- Python基础之基本语法及数据类型
- Python学习笔记一:数据类型与基本操作
- python入门--基本数据类型
- Python入门基本语法
- python入门--基本语法
- Swift学习笔记之基本数据类型-数组与字典
- python基本数据类型笔记
- 【python学习笔记二】基本数据类型
- ubuntu NTP 配置
- Phone List (POJ_3630) 静态字典树 + 模板题
- jquery的each()详细介绍
- trie数和后缀树
- 修改Maven的本地仓库路径
- python 入门学习笔记之基本语法与基本数据类型
- ZOJ - 3469 Food Delivery 区间DP
- [绍棠] xcode APP 打包以及提交apple审核详细流程(新版本更新提交审核)
- 第26讲项目2——成绩等级
- NYOJ-487月老的烦恼(1)类似于素数筛法一样的打表及一种筛法核心代码。。
- 15. SpringMVC 执行定时任务,处理静态资源,配置视图解析器
- codeforces 630F Selection of Personnel(组合数)
- poj 2152 Fire
- Java robot类的getPixelColor问题