当前位置: 首页 > news >正文

网站被k表现网页制作详细教程

网站被k表现,网页制作详细教程,深圳市建设工程造价管理站官网,功能型网站建设数据容器-----元组 定义格式,特点,相关操作 元组一旦定义,就无法修改 元组内只有一个数据,后面必须加逗号 """ #元组 (1,"hello",True) #定义元组 t1 (1,"hello") t2 () t3 tuple() prin…

数据容器-----元组

定义格式,特点,相关操作

元组一旦定义,就无法修改

元组内只有一个数据,后面必须加逗号

"""
#元组
(1,"hello",True)
#定义元组
t1 = (1,"hello")
t2 = ()
t3 = tuple()
print(f"t1的类型是{type(t1)}")
#单个元素后面需要加逗号
t4 = ("hello",)
print(f"t4的类型是{type(t4)}")
#元素的嵌套
t5 = ((1,2,3),(4,5,6))
print(f"t5的类型是{type(t5),},内容是{t5}")
#下标索引去取内容
element = t5[1][1]
print(element)
#index查找方法
t6 = ("heima","heima","hij","sda")
index = t6.index("hij")
print(f"在元组t6中查找hij,的下标是:{index}")
#元组的操作:count统计方法
num = t6.count("heima")
print(f"在元组t6中,heima的数量是{num}")t8 = ("hins","heima","heima","hij","sda")
num1 = len(t8)
print(f"t8元组中,元素的个数为{num1}")
#while循环
#for 循环遍历
t1 = (1,2,3,4,5,6)
for element in t1:print(f"t1中的元素分别为{element}")t1 = (1,2,3,4,5,6)
index = 0
while index<len(t1):print(f"t1中的元素分别为{t1[index]}")index += 1#元组不支持修改元素
t1 = (1,2,3)
t1[0]=4
print(t1)
"""
#元组内的列表内容可以修改
t2 = (1,2,3,[4,5,6,7])
t2[3][0]=8
print(t2)

t1 = ("周杰伦",11,["football","music"])
index = t1.index("周杰伦")
print(f"周杰伦年龄所在的下标位置是{index}")
name = t1[0]
print(f"该学生的姓名为{name}")
t1[2][0]=()
print(t1)
t1[2][0]="coding"
print(t1)

2.掌握字符串的常见操作

#字符串的替换
#得到的是一个新字符串而并非将原有字符串修改
my_str = "itheima and itcast"
my_str2 = my_str.replace("and","beautiful")
print(my_str2)
print(my_str)

"""
#元组
(1,"hello",True)
#定义元组
t1 = (1,"hello")
t2 = ()
t3 = tuple()
print(f"t1的类型是{type(t1)}")
#单个元素后面需要加逗号
t4 = ("hello",)
print(f"t4的类型是{type(t4)}")
#元素的嵌套
t5 = ((1,2,3),(4,5,6))
print(f"t5的类型是{type(t5),},内容是{t5}")
#下标索引去取内容
element = t5[1][1]
print(element)
#index查找方法
t6 = ("heima","heima","hij","sda")
index = t6.index("hij")
print(f"在元组t6中查找hij,的下标是:{index}")
#元组的操作:count统计方法
num = t6.count("heima")
print(f"在元组t6中,heima的数量是{num}")t8 = ("hins","heima","heima","hij","sda")
num1 = len(t8)
print(f"t8元组中,元素的个数为{num1}")
#while循环
#for 循环遍历
t1 = (1,2,3,4,5,6)
for element in t1:print(f"t1中的元素分别为{element}")t1 = (1,2,3,4,5,6)
index = 0
while index<len(t1):print(f"t1中的元素分别为{t1[index]}")index += 1#元组不支持修改元素
t1 = (1,2,3)
t1[0]=4
print(t1)#元组内的列表内容可以修改
t2 = (1,2,3,[4,5,6,7])
t2[3][0]=8
print(t2)#练习
t1 = ("周杰伦",11,["football","music"])
index = t1.index("周杰伦")
print(f"周杰伦年龄所在的下标位置是{index}")
name = t1[0]
print(f"该学生的姓名为{name}")
t1[2][0]=()
print(t1)
t1[2][0]="coding"
print(t1)my_str = "itheima and itcast"
value = my_str[0]
print(value)
value2 = my_str[-1]
print(value2)
#字符串不支持修改
my_str[0]="1"
print(my_str)#字符串的index方法
my_str = "itheima and itcast"
value = my_str.index("and")
print(f"在字符串中查找and,其起始下标是{value}")#字符串的替换
#得到的是一个新字符串而并非将原有字符串修改
my_str = "itheima and itcast"
my_str2 = my_str.replace("and","beautiful")
print(my_str2)
print(my_str)#字符串的切分
my_str = "itheima and itcast"
mystr2 = my_str.split()
print(my_str)
print(mystr2,f"类型是{type(mystr2)}")#字符串的归整操作(去前后空格)
#不传入参数,去除收尾空格
my_str = "  itheima and itcast  "
newstr = my_str.strip()
print(my_str)
print(newstr)#去除收尾指定元素
my_str = "2314itheima and itcast231"
newstr = my_str.strip("2314")
print(newstr)
#统计元素出现次数
count = my_str.count("i")
print(count)#统计长度
my_str = "2314itheima and itcast231"
length = len(my_str)
print(length)#字符串的遍历
#while
mystr = "lili is a good boy"
index = 0
while index <len(mystr):print(f"该字符串的元素为{mystr[index]}")index += 1#for循环
mystr = "lili is a good boy"
for element in mystr:print(f"该字符串的元素为{element}")
"""

mystr = "itheima itcast boxuegu"
count = mystr.count("it")
print(f"字符串中it一共有{count}个")
newstr = mystr.replace(" ","|")
print(newstr)
new2 = newstr.split("|")
print(new2)
http://www.yayakq.cn/news/551741/

相关文章:

  • 建设工程 质量 协会网站网络推广内容策划
  • 重庆市设计公司网站网站怎么进行优化
  • 51一起做网站网站关键词更改
  • 东莞企业网站定制设计南昌有哪些做网站的公司
  • 影楼网站怎么做wordpress 3.5 下载
  • 评网网站建设成都网站开发公司
  • 大作业做网站代理记账包含哪些业务
  • 给别人做网站别人违法经营6第三方维护公司
  • 驻马店市建设工程网站优化培训学校
  • 怎么查看网站ftp地址课程精品网站开发
  • 执业医师变更注册网站艺术字体转换器在线转换器
  • 彩妆做推广的网站网站建设方案书的内容
  • 网站新闻列表怎么做齐家网装修
  • 做机械产品用什么网站陕西省建设网三类人员证书打印
  • 潍坊网站制作案例海外推广渠道
  • 网站策划书wordpress 请求
  • 网站制作是不是要先用ps做兴义网站开发
  • 网站后台的建设网页设计实验报告格式模板
  • 沈阳德泰诺网站建设公司 概况站长工具网址查询
  • 临淄哪里做网站wordpress免费中文完整版主题下载
  • 深圳微信网站建设企业安全文化建设中的安全承诺
  • 制作网站哪家专业网站建设方案报价费用明细价格
  • 音乐网站源码带手机版做外贸首先要做网站
  • 网站开发基本流程图h5 做的网站 价格
  • 免费申请网站空间及域名如何做好网站推广
  • 南宁做网站推广wordpress分类信息插件
  • 太原网站制作报价网站建设有哪些方法
  • 网站建设维护人员什么是网络营销推广
  • 乐清站在那儿谷歌云 wordpress
  • 界面做的最好的网站杭州软件开发培训机构