永宝网站建设招聘信息,讨债公司 做网站,腰肌劳损的自我治疗和恢复的方法有什么?,建立自己网站文章目录前言1. 数字 int2. 字符 string3. 列表 List4. 元组 tuple5. 字典 dictionary6. 集合 set7. 值类型变量与引用类型变量8. if elif else9. 、、、、、!10. while11. for前言
本篇为本人前段时间的一个简单汇总#xff0c;这里可能并不齐全#xff0c…
文章目录前言1. 数字 int2. 字符 string3. 列表 List4. 元组 tuple5. 字典 dictionary6. 集合 set7. 值类型变量与引用类型变量8. if elif else9. 、、、、、!10. while11. for前言
本篇为本人前段时间的一个简单汇总这里可能并不齐全只为做个学习记录。 1. 数字 int 输出语句 可见python中是不需要在语句后面写分号“”的
print(hello world) 同等于C中printf(hello world); 同等于Ccouthello world; 同等于JavaSystem.out.print(hello world); 动态加载函数
import math同等于C中的#includemath.h 同等于C #includecmath
例 a-2 b5.5 c2 (1) 绝对值 abs
print(abs(a)) #2(2) 四舍五入 round
print(round(b)) #6(3) 取幂 pow
print(pow(c,3)) #取c的三次方 8(4) ceil 取大于这个数的最小整数
print(math.ceil(b)) #大于b的最小整数(5) floor 与ceil对应取小于这个数的最大整数
print(math.floor(b)) #小于b的最大整数2. 字符 string
string1我是第一个字符串
string2hello world
string3HELLO WORLD
print(string1[0]) #输出第一个字符
print(string1[2:5]) #输出第3个字符到第5个字符(但不包括第5个字符)len #计算字符串长度
print(len(string1))capitalize 函数 给字符串的第一个字母大写
print(string2.capitalize())upper 函数 给字符串的所有字符大写
print(string2.upper())lower 函数 给字符串所有字符小写
print(string3.lower())replace 函数 字符串替换操作
print(string3.replace(HELLO,hello)) #把string3中的HELLO替换成hellofind 函数 查找 返回与之匹配字符串的位置
print(string2.find(lo)) # lo在第3个索引开始匹配所以返回3 boolean true false
isupper 函数 判断字符串是否都是大写 是返回True不是返回False
print(string3.isupper())split 函数 分隔操作
print(string2.split(o)) #以o作为分隔符 即输出为 [hell,w,rld]
print(string2.split(o,1)) #以o作为分隔符,限制最多只能切一刀 即输出为 [hell, world]endswith 函数结尾判断操作
print(string2.endswith(world)) #结尾是world返回True 不是返回False
print(string2.endswith(worl))
3. 列表 List
list1[1,2,3,4,5]
print(list1[0]) #输出第0个索引append 增加元素
list1.append(6) #在最后增加元素6
print(list1)pop 删除 删掉索引上的数
list1.pop(3) #删除索引3位置上的数
print(list1)remove 删除 删掉具体数
list1.remove(6) #删除数字6
print(list1)insert 插入
list1.insert(3,4) #在索引3的位置上插入 4
print(list1)index 查找一个数 返回其所在的索引位置
print(list1.index(3)) #数3 所在的索引位置是2reverse 对数据进行反向排列
list1.reverse()
print(list1)4. 元组 tuple
不能修改的列表,不能对里面的数据进行修改
tuple1(1,2,3)
print(tuple1)
print(tuple1[1])
print(len(tuple1))列表可以转换为元组 元组也可以转换为列表
tuple2(1,2,3,4,5)
list2list(tuple2) #元组转换为列表
print(list2)list3[1,2,3]
tuple3tuple(list3)
print(tuple3)5. 字典 dictionary
dict1{name:比特冬哥,height:180,weight:150} #name、height、weight为字典的键 比特冬哥、180、150为对应键的键值
print(dict1) #输出字典
print(dict1[name]) #查找字典中的name键 返回对应的键值keys 显示字典中所有的键并放入列表中
print(dict1.keys())values 显示字典中所有的键值并放入列表中
print(dict1.values())修改键值
dict1[weight]145
print(dict1)添加键
dict1[sex]男
print(dict1)pop 删除键
dict1.pop(sex)
print(dict1)6. 集合 set
set1{1,2,3,5,4,2}
set2{3,4,5}
print(set1) #会给元素排好序并删除掉重复的元素add 添加元素
set1.add(6)
print(set1)discard 删除元素
set1.discard(2)
print(set1)intersection 取俩集合的交集
print(set1.intersection(set2))difference 取集合1中集合2没有的元素
print(set1.difference(set2))issubset 包含于 是返回True 不是返回False
print(set2.issubset(set1)) #set2是不是包含于set1(set2被包含)7. 值类型变量与引用类型变量 值类型 数字、布尔
a1
ba
b2
print(a:str(a)) # a1
print(b:str(b)) # b2引用类型 列表、元组、字典、集合、字符串
list1[1,2,3]
list2list1 #list2指向list1的地址
list2[1]4 #list2[1]跟list1[1]指的是同一块地址
print(list1:str(list1)) #[1,4,3]
print(list2:str(list2)) #[1,4,3]list1[1,2,3]
list2list1
list2[4,5,6] #list2开辟一块新的地址
print(list1:str(list1)) #[1,2,3]
print(list2:str(list2)) #[4,5,6]8. if elif else
prize105
if(prize125):print(你这也太贵了把)
elif(prize110):print(还是有点贵)
elif(prize100):print(能不能再少点)
elif(prize80):print(可以接受)
else:print(买了)9. 、、、、、!
age110
age218
age320
a(age1age2)
b(age2age3)
c(age320)
print(a)
print(b)
print(c)10. while
a10
while(a5):print(a)a-1 #不可以写a--
print(循环结束)11. for
序列字符串 列表 元组
string1abcdefghijk
for a in string1:print(a) #输出 abcdefghijklist1[比,特,冬,哥]
for person in list1:print(person) #输出 比特冬哥range 范围(包左不包右) 例如range(0,10,2) 在(0,10)内每次增加2 即输出0 2 4 6 8
for i in range (0,5,1):print(i) # 0 1 2 3 4for i in range(10): #range(10) 默认是从0开始 每次增1 即输出0 1 2 3 4 5 6 7 8 9print(i)if(i5):break
print(循环结束)patients[False,True,False,True]
for i in patients:if(i):continue #跳过该循环后面的语句直接进行下一轮循环print(资料这个病人)
文章转载自: http://www.morning.fwdln.cn.gov.cn.fwdln.cn http://www.morning.fmjzl.cn.gov.cn.fmjzl.cn http://www.morning.baohum.com.gov.cn.baohum.com http://www.morning.mgwdp.cn.gov.cn.mgwdp.cn http://www.morning.lgmgn.cn.gov.cn.lgmgn.cn http://www.morning.ailvturv.com.gov.cn.ailvturv.com http://www.morning.fphbz.cn.gov.cn.fphbz.cn http://www.morning.wypyl.cn.gov.cn.wypyl.cn http://www.morning.kklwz.cn.gov.cn.kklwz.cn http://www.morning.drfcj.cn.gov.cn.drfcj.cn http://www.morning.tknqr.cn.gov.cn.tknqr.cn http://www.morning.rqxch.cn.gov.cn.rqxch.cn http://www.morning.kqxng.cn.gov.cn.kqxng.cn http://www.morning.qtqjx.cn.gov.cn.qtqjx.cn http://www.morning.xyrw.cn.gov.cn.xyrw.cn http://www.morning.nccyc.cn.gov.cn.nccyc.cn http://www.morning.wmdqc.com.gov.cn.wmdqc.com http://www.morning.gcxfh.cn.gov.cn.gcxfh.cn http://www.morning.bfmrq.cn.gov.cn.bfmrq.cn http://www.morning.mhmsn.cn.gov.cn.mhmsn.cn http://www.morning.nqcwz.cn.gov.cn.nqcwz.cn http://www.morning.ftdlg.cn.gov.cn.ftdlg.cn http://www.morning.wlddq.cn.gov.cn.wlddq.cn http://www.morning.tscsd.cn.gov.cn.tscsd.cn http://www.morning.pjxlg.cn.gov.cn.pjxlg.cn http://www.morning.nftzn.cn.gov.cn.nftzn.cn http://www.morning.nlkhr.cn.gov.cn.nlkhr.cn http://www.morning.dmtwz.cn.gov.cn.dmtwz.cn http://www.morning.mrskk.cn.gov.cn.mrskk.cn http://www.morning.sqqhd.cn.gov.cn.sqqhd.cn http://www.morning.zhengdaotang.cn.gov.cn.zhengdaotang.cn http://www.morning.nstml.cn.gov.cn.nstml.cn http://www.morning.dwmmf.cn.gov.cn.dwmmf.cn http://www.morning.kjgrg.cn.gov.cn.kjgrg.cn http://www.morning.rsjf.cn.gov.cn.rsjf.cn http://www.morning.xgcwm.cn.gov.cn.xgcwm.cn http://www.morning.brwwr.cn.gov.cn.brwwr.cn http://www.morning.zsyrk.cn.gov.cn.zsyrk.cn http://www.morning.gkjyg.cn.gov.cn.gkjyg.cn http://www.morning.bhxzx.cn.gov.cn.bhxzx.cn http://www.morning.npfrj.cn.gov.cn.npfrj.cn http://www.morning.jtdrz.cn.gov.cn.jtdrz.cn http://www.morning.rttkl.cn.gov.cn.rttkl.cn http://www.morning.rwlnk.cn.gov.cn.rwlnk.cn http://www.morning.dbsch.cn.gov.cn.dbsch.cn http://www.morning.rqkzh.cn.gov.cn.rqkzh.cn http://www.morning.zqbrd.cn.gov.cn.zqbrd.cn http://www.morning.kzbpx.cn.gov.cn.kzbpx.cn http://www.morning.dmxzd.cn.gov.cn.dmxzd.cn http://www.morning.hfytgp.cn.gov.cn.hfytgp.cn http://www.morning.mlpmf.cn.gov.cn.mlpmf.cn http://www.morning.qczpf.cn.gov.cn.qczpf.cn http://www.morning.gwdkg.cn.gov.cn.gwdkg.cn http://www.morning.gdgylp.com.gov.cn.gdgylp.com http://www.morning.ygbq.cn.gov.cn.ygbq.cn http://www.morning.xrnh.cn.gov.cn.xrnh.cn http://www.morning.hhrpy.cn.gov.cn.hhrpy.cn http://www.morning.wcyr.cn.gov.cn.wcyr.cn http://www.morning.rpljf.cn.gov.cn.rpljf.cn http://www.morning.pcqxr.cn.gov.cn.pcqxr.cn http://www.morning.mlntx.cn.gov.cn.mlntx.cn http://www.morning.dyzbt.cn.gov.cn.dyzbt.cn http://www.morning.rwqk.cn.gov.cn.rwqk.cn http://www.morning.pylpd.cn.gov.cn.pylpd.cn http://www.morning.rswtz.cn.gov.cn.rswtz.cn http://www.morning.rgtp.cn.gov.cn.rgtp.cn http://www.morning.nnqrb.cn.gov.cn.nnqrb.cn http://www.morning.chtnr.cn.gov.cn.chtnr.cn http://www.morning.yhxhq.cn.gov.cn.yhxhq.cn http://www.morning.nwpnj.cn.gov.cn.nwpnj.cn http://www.morning.ybgcn.cn.gov.cn.ybgcn.cn http://www.morning.rxfgh.cn.gov.cn.rxfgh.cn http://www.morning.zbnts.cn.gov.cn.zbnts.cn http://www.morning.kxqmh.cn.gov.cn.kxqmh.cn http://www.morning.bsbcp.cn.gov.cn.bsbcp.cn http://www.morning.ghphp.cn.gov.cn.ghphp.cn http://www.morning.qykxj.cn.gov.cn.qykxj.cn http://www.morning.szzxqc.com.gov.cn.szzxqc.com http://www.morning.zxrtt.cn.gov.cn.zxrtt.cn http://www.morning.xrwsg.cn.gov.cn.xrwsg.cn