python数据操作--8
2024-09-08 10:17:32
转:https://www.tuicool.com/wx/MB7nieb
数据类型
- 整数,
- 浮点数,
- 字符串,
- 布林值(True,False)
- 列表(list),
- 不可变的列表 Tuple,
- 集合(没有顺序的概念),set
- 字典(key value pair),
- 变量.
后面其实就是解析一下上面的数据类型是如何使用,有那些规则。
说明
列表是有顺序分可修改和不可修改两种。
[ ] 代表列表,[3,4,5] [‘hello’,’world’],中括号
不能修改的列表 tuple,括号
(3,4,5) , (‘hello’, ‘world’)
集合 set,没有顺序的概念,大括号
{3,4,5}
字典
{‘apple’: ‘苹果’, ‘data’:’数据’}
变量,可以是任意字母,开头不能是数字
字符串
A='hello'
B='world'
C=A*3+B
print (C)
打印出来就是
hellohellohelloworld
x**y 次方
单引号,双引号,多行文字
整数除法 7//6 =1
小数除法 7/6
取余数 7%6 1
s=’hello’
print(s[1:4])
密码换位
A=input('请输入你的密码,可以数字,特殊符号和文字:') L=len(A) print (A[3:L]+A[0:3])
print (A[3:]+A[:3])
上面的写法,
A=[12,60,15,70,90]
A[0]=50
print (A)
A[1:4]=[]
print (A)
对列表的12,更新成50,删除内容
[50, 60, 15, 70, 90]
[50, 90]
最新文章
- ASP.NET MVC5----了解我们使用的@HTML帮助类
- BZOJ 2693: jzptab [莫比乌斯反演 线性筛]
- mysql select语句解析
- jenkins配置记录(2)--代码发布流程
- OPENSSL编程入门学习
- 北邀 E Elegant String
- 布局(layout)文件图形界面不能显示:An error has occurred. See error log for more details. java.lang.NullPointe
- 帝国cms7.0整合百度编辑器ueditor教程
- div内嵌p,div等块元素出现的问题
- 枚举算法总结 coming~^.*
- 关于laravel框架的跨域请求/jsonp请求的理解
- python学习笔记1-python相关应用套件
- Mysql必知必会 第一章 了解SQL
- Error:Failed to resolve: com.android.support:appcompat-v7
- JMeter学习-041-响应数据中文乱码解决方法
- [HDU1598]find the most comfortable road
- centos php Zookeeper kafka扩展安装
- const的详解
- 开发移动端web页面click事件失效问题
- python 在Unicode和普通字符串 str 之间转换
热门文章
- 【LeetCode】34. Find First and Last Position of Element in Sorted Array 解题报告(Python & C++)
- 【LeetCode】825. Friends Of Appropriate Ages 解题报告(Python)
- 【LeetCode】678. Valid Parenthesis String 解题报告(Python)
- vue create 初步解析以及定制化修改
- css--深入理解z-index引发的层叠上下文、层叠等级和层叠顺序
- uniCloud爬虫获取网页数据
- [黑科技]pb_ds库(G++)
- MySQL高级查询与编程笔记 • 【目录】
- Eclipse中英文对照表(整理笔记)
- 加深理解Java异常概念并熟记5个最常见的运行时异常