当前位置:网站首页>数值类型和数列类型
数值类型和数列类型
2022-04-22 22:40:00 【小木猿】
# 查看变量类型时用type()方法
# a=10
# b=10.0
# a==b
# ture
# a is b
#false
# 一般的加减乘除:+,-,*,/
# 整除://
# 取余:%
# 幂运算:**
# decimal计算(精确计算)
# from decimal import *
# print(Decimal(55.9))
#
import decimal
print(decimal.Decimal(55.9))
# 复数运算
b=3+5j
print(b*b)
# 字典属于散列
name=['风','小','bing','d','s','1','3','4']
print(name[0])
print(name[0:2])
sex=['按钮','男']
# print(name+sex) 左闭右开
# print(name[:]) 切取全部
print(name[:4]) #等同于[0:4]
print(name[0:]) #切取到最后,取最后一位
print(name[::2]) #2代表步长
print(name[::-1]) #a代表逆序
print(name[2:7:-1]) #结果为空,自右往左
print(name[7:2:-1])
# 看第三个参数
#分辨正负号
# 走切片流程,如果是负,那么切片索引是从右往左
print(name[0:10])#如果超出范围,切取到最后、
print(name[-1])
print(name[-0])
print(len(name))#len查看长度
print(name*3) #可以相乘
print(.85) #自动补齐
#列表之间不能相减
name[1]=6
print(name)
版权声明
本文为[小木猿]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_59073956/article/details/124348721
边栏推荐
猜你喜欢

Minio基本使用与原理

cluster_acc计算

Person re identification: past, present and future

Multi thread thread communication (wait notify, await single, park unpark)

Appinventor development

【论文代码复现】Translating Embeddings for Modeling Multi-relational Data中TransE代码实现+遇到的错误

CSV column extract column extraction

多线程进阶(八)----线程池

用 Flutter 写一个精美的登录页面(最新版)

USPS数据集_kmeans使用总结
随机推荐
Appinventor development
数组去重-基本数据类型
讲座录播|图数据库中的子图匹配算法-邹磊
USPS数据集_kmeans使用总结
scanpy find resolution
Multithreading advanced (7) -- optimistic lock and pessimistic lock
fastadmin 动态赋值下拉框
MTP管理课者养成计划-第1天学习笔记
LLVM 学习(一) -初识LLVM
L1-066 猫是液体 (5 分)
Gentoo系统安装步骤详解
Acl2022 | using Chinese language hierarchy heterogeneity map to strengthen the pre training language model
Knowledge map opening notes
牛客BM41. 输出二叉树的右视图
The PMP certificate has expired. Is it necessary to renew it
Anti DDoS attack forwarding IP. Is the advanced anti IP of chess and card games easy to use?
js力扣每日一题(2022/4/22)---396.旋转函数
GDB调试程序的核心技术-ptrace系统调用与使用示例
41.0:GemBox. Spreadsheet|. Document|. Pdf|. Presentation
L1-071 前世档案 (20 分)