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

网站基本功能郑州平面设计公司排行榜

网站基本功能,郑州平面设计公司排行榜,互联网网站制作公司,国内十强少儿编程机构""" 演示tuple元组的定义和操作 """# 元组一旦定义完成,就不可修改 # 定义元组 # t1 (1, "Hello", True) # t2 () # 定义空元组 # t3 tuple() #定义空元组 # print(f"t1的类型是:{type(t1)}, 内容是&…
"""
演示tuple元组的定义和操作
"""# 元组一旦定义完成,就不可修改
# 定义元组
# t1 = (1, "Hello", True)
# t2 = ()  # 定义空元组
# t3 = tuple()  #定义空元组
# print(f"t1的类型是:{type(t1)}, 内容是:{t1}")
# print(f"t2的类型是:{type(t2)}, 内容是:{t2}")
# print(f"t3的类型是:{type(t3)}, 内容是:{t3}")
#
# # 定义单个元素的元组
# # 如果元组里只有一个元素就必须在后面写逗号,如果不写就是字符串类型
# t4 = ("hello",)
# print(f"t4的类型是:{type(t4)}, t4的内容是:{t4}")
# # 元组的嵌套
# t5 = ( (1, 2, 3), (4, 5, 6) )
# print(f"t5的类型是:{type(t5)}, 内容是:{t5}")
#
# # 下标索引去取出内容
# num = t5[1][2]
# print(f"从嵌套元组中取出的数据是:{num}")
#
# # 元组的操作:index查找方法
# t6 = ("传智教育", "黑马程序员", "Python")
# index = t6.index("黑马程序员")
# print(f"在元组t6中查找黑马程序员,的下标是:{index}")
# # 元组的操作:count统计方法
# t7 = ("传智教育", "黑马程序员", "黑马程序员", "黑马程序员", "Python")
# num = t7.count("黑马程序员")
# print(f"在元组t7中统计黑马程序员的数量有:{num}个")
# # 元组的操作:len函数统计元组元素数量
# t8 = ("传智教育", "黑马程序员", "黑马程序员", "黑马程序员", "Python")
# num = len(t8)
# print(f"t8元组中的元素有:{num}个")
# # 元组的遍历:while
# index = 0
# while index < len(t8):
#     print(f"元组的元素有:{t8[index]}")
#     # 至关重要
#     index += 1
#
# # 元组的遍历:for
# for element in t8:
#     print(f"2元组的元素有:{element}")
#
# # 不能修改元组内容,元组定义后不能修改
# # t8[0] = "itcast"
# # print(t8[0])
#
# # 定义一个元组,元组内的第一层元素不能修改,但第二层元素如list内的元素可修改
# t9 = (1, 2, ["itheima", "itcast"])
# print(f"t9的内容是:{t9}")
# t9[2][0] = "黑马程序员"
# t9[2][1] = "传智教育"
# print(f"t9的内容是:{t9}")# 小练习
# t10=('周杰伦',11,['football','music'])
# print(t10.index(11))
# print(t10[0])
# t10[2].remove('football')
# print(t10)
# t10[2].append("coding")
# print(t10)"""
演示以数据容器的角色,学习字符串的相关操作
"""
# my_str = "itheima and itcast"
# # 通过下标索引取值
# value = my_str[2]
# value2 = my_str[-16]
# print(f"从字符串{my_str}取下标为2的元素,。值是:{value},取下标为-16的元素。值是:{value2}")
#
# # 不能修改字符串对应位置的值
# # my_str[2] = "H"
#
# # index方法
# value = my_str.index("and")
# print(f"在字符串{my_str}中查找and,其起始下标是:{value}")
#
# # replace方法,原字符串不变,得到一个替换后的新字符串
# new_my_str = my_str.replace("it", "程序")
# print(f"将字符串{my_str},进行替换后得到:{new_my_str}")
#
# # split方法
# my_str = "hello python itheima itcast"
# my_str_list = my_str.split(" ")
# print(f"将字符串{my_str}进行split切分后得到:{my_str_list}, 类型是:{type(my_str_list)}")
#
# # strip方法
# my_str = "  itheima and itcast  "
# new_my_str = my_str.strip() # 不传入参数,去除首尾空格
# print(f"字符串{my_str}被strip后,结果:{new_my_str}")
#
# my_str = "12itheima and itcast21"
# new_my_str = my_str.strip("12")
# print(f"字符串{my_str}被strip('12')后,结果:{new_my_str}")
#
# # 统计字符串中某字符串的出现次数, count
# my_str = "ithaha and itheihei"
# count = my_str.count("it")
# print(f"字符串{my_str}中it出现的次数是:{count}")
# # 统计字符串的长度, len()
# num = len(my_str)
# print(f"字符串{my_str}的长度是:{num}")# 小练习
str="ithaha itlala boxixi"
num=str.count("it")
print(f"有{num}个\"it\"字符")
newstr=str.replace(" ","|")
print(newstr)
newstr2=newstr.split("|")
print(newstr2)
http://www.yayakq.cn/news/251222/

相关文章:

  • 做啥网站最挣钱昆山设计公司
  • 如何申请开通网站企业网站建设要注意哪方面
  • 自己想建设一个网站网站优化建设安徽
  • 用js做的网站代码吗wordpress flash加载插件
  • 有特效的网站通过ip访问网站需要怎么做
  • 网站要怎么上传在线做图软件
  • 网站推广攻略wordpress代码目录
  • 苏州品牌网站建设网站排名方法
  • 在线制作网站地图深圳宝安区松岗
  • 女人与狗做视频网站辽源网站建设
  • 门户网站模版做纺织都有那些好网站
  • 汉中专业网站建设推广移动端网站怎么做seo
  • 天津专门做网站的公司wordpress音频播放
  • 社区做图网站wordpress 图片域名
  • 门户网站建设需求文档恒基建设集团网站地址
  • 厦门市建设工程造价网站首页网搜网
  • 可信赖的广州做网站指数是什么
  • 做网站 信科网络公众号第三方建微网站
  • c 做网站教程wordpress图片七牛云加速
  • 网站建设每年需要交多少钱先看网站案例您的网站也可以这么做
  • 建网站多少钱一个月企业建设网站的主要作用
  • 手机软件上传网站在线生成网页工具
  • 网站建设通查询东莞城建局电话是多少
  • 求个a站干煤棚网架公司
  • 马鞍山网站开发小程序app系统开发
  • 广州网站建设外包广州清洁公司
  • 永久免费自助建站系统移动应用开发是什么意思
  • 网站建设 主机托管深圳返利网站开发
  • 如何在税局网站上做税种认定做网站网站要找谁
  • 行业网站导航开封市城乡建设局网站