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

网站建设人员如何利用互联网宣传与推广

网站建设人员,如何利用互联网宣传与推广,b2c电商网站账户,黄骅贴吧最新招聘信息一、正则表达式 1.基础匹配 学习目标:了解什么是正则表达式,掌握re模块的基础使用 就是一种规则的定义,通过规则去验证给定的目标是否符合定义的规则。 正则的三个基础方法 match match是匹配开头,开头有python就算匹配成功&a…

一、正则表达式

1.基础匹配

学习目标:了解什么是正则表达式,掌握re模块的基础使用

就是一种规则的定义,通过规则去验证给定的目标是否符合定义的规则。

正则的三个基础方法

match

match是匹配开头,开头有python就算匹配成功,没有就是不成功,只要开头不匹配后面的根本不关心。

span(0,6)说的是下标从0到6

search

从头开始找,只找一个,后面的不予理会

findall

找出来所有相匹配的数据,以列表的形式输出出来。

"""
演示python正则表达式re模块的3个基础匹配方法
"""
import re
s = "1python itheima python"
# match 从头匹配
result = re.match("1python",s)
print(result)
print(result.span())
print(result.group())
# search 搜索匹配
result = re.search("python",s)
print(result)# findall 搜索全部匹配
result = re.findall("python",s)
print(result)

总结

2.元字符匹配

学习目标:掌握正则表达式的各类元字符规则,了解字符串的r标记的作用。

单字符匹配

因为反斜杠\有具体的含义,可能代表转义字符,所以给字符串一个r标记,表示字符串中转义字符无效,就是普通字符的意思。

找出全部的数字

找出特殊符号  \W(大写的W)

找出全部英文字母

使用[],[]里面可以写想要的规则范围,可以自己规定范围

元字符匹配

小练习

findall如果我们的正则表达式里面有分组,就会把每一个组的结果都给你列出来

因此我们也可以使用match

"""
演示python正则表达式使用元字符进行匹配
"""
import re# 匹配账号,只能由字母和数字组成,长度限制6到10位
# r = '^[0-9a-zA-Z]{6,10}$'  # ^ $表示从头开始匹配,匹配到最后结尾。在正则里面,不要随意加空格。
# s = '124343'
# s1 = 'adhalod'
# s2 = '2s233s2'
# s3 = '...d7dd'
# print(re.findall(r,s))
# print(re.findall(r,s1))
# print(re.findall(r,s2))
# print(re.findall(r,s3))
# 匹配QQ号,要求纯数字,长度5~11,第一位不为0
# r = '^[1-9][0-9]{4,10}$'   # 不写范围就是默认是一个数
# s = '013131'
# s1 = '347834'
# s2 ='233ew23'
# print(re.findall(r,s))
# print(re.findall(r,s1))
# print(re.findall(r,s2))
# 匹配邮箱地址,只允许qq、163、gmail这三种邮箱地址
# 邮箱地址大体是{内容}.{内容}@{内容}.{内容}.{内容} acd.cdac.acd@qq.adf
r =r'(^[\w-]+(\.[\w-]+)*@(qq|163|gmail)(\.[\w-]+)+$)'
s = 's.ds.dsada.as@qq.aif.fdsiad'
print(re.match(r,s))

总结

二、递归

学习目标:掌握什么是递归,掌握递归案例的开发。

那么什么样的场景会用到递归呢?

比如来说,如果你是文件夹,我就再调用自己再进去看看,如果你不是,我就收集文件

就是说一个文件夹,进去发现是文件就返回给上一层,是文件夹就在进入这个文件夹看是文件还是文件夹,不断的返回给上一层最后就把全部的文件都收集到了

说起来比较抽象,让我们用代码演示一下。

实战演示

大家也可以自己创建一个如图所示的文件夹来试试代码能否正常运行。

"""
演示python进行排序
需求:通过递归,找出一个指定文件夹的全部文件思路:写一个函数,列出文件夹内的全部内容,如果是文件就收集到list
如果是文件夹,就递归调用自己,再次判断
"""
import os
def test_os():"""演示os模块的三个基础方法"""print(os.listdir("D:/test"))  # 可以帮我们列举出指定文件夹里面有哪些内容print(os.path.isdir("D:/test/a"))  # 判断你给的路径是否是一个文件夹print(os.path.exists("D:/test"))  # 判断指定路径是否存在def get_files_recursion_from_dir(path):print(f"当前判断的文件夹是:{path}")file_list = []"""从指定的文件夹中使用递归的方式,获取全部的文件列表:param path:被判断的文件夹:return:list,包含全部的文件,如果目录不存在或者无文件就返回一个空list"""if os.path.exists(path):for f in os.listdir(path):new_path = path + "/" + fif os.path.isdir(new_path):# 进入到这里,表示这个目录是文件夹不是文件file_list += get_files_recursion_from_dir(new_path)else:file_list.append(new_path)else:print(f"指定的目录{path},不存在")return []return file_list
if __name__ == '__main__':print(get_files_recursion_from_dir("D:/test"))

总结


文章转载自:
http://absolve.rdfq.cn
http://intergalactic.rdfq.cn
http://meloid.rdfq.cn
http://russophile.rdfq.cn
http://lacelike.rdfq.cn
http://waif.rdfq.cn
http://gasdynamics.rdfq.cn
http://separate.rdfq.cn
http://khapra.rdfq.cn
http://neonatology.rdfq.cn
http://feoffee.rdfq.cn
http://matronly.rdfq.cn
http://lubricator.rdfq.cn
http://valeta.rdfq.cn
http://inclemency.rdfq.cn
http://obstetric.rdfq.cn
http://dollishness.rdfq.cn
http://tael.rdfq.cn
http://shafting.rdfq.cn
http://irradiator.rdfq.cn
http://holistic.rdfq.cn
http://airmark.rdfq.cn
http://vanish.rdfq.cn
http://tied.rdfq.cn
http://balistraria.rdfq.cn
http://pee.rdfq.cn
http://anodal.rdfq.cn
http://gain.rdfq.cn
http://millpond.rdfq.cn
http://explodent.rdfq.cn
http://gestaltist.rdfq.cn
http://expedient.rdfq.cn
http://crepuscle.rdfq.cn
http://crucifix.rdfq.cn
http://shrew.rdfq.cn
http://cineprojector.rdfq.cn
http://avoid.rdfq.cn
http://fiddleback.rdfq.cn
http://hairologist.rdfq.cn
http://groundling.rdfq.cn
http://antichloristic.rdfq.cn
http://nabi.rdfq.cn
http://radiosonde.rdfq.cn
http://burgh.rdfq.cn
http://inclinable.rdfq.cn
http://irreproducible.rdfq.cn
http://semidomesticated.rdfq.cn
http://gland.rdfq.cn
http://poniard.rdfq.cn
http://yahwism.rdfq.cn
http://clocklike.rdfq.cn
http://horrible.rdfq.cn
http://quietish.rdfq.cn
http://syllepsis.rdfq.cn
http://echinodermata.rdfq.cn
http://crocoite.rdfq.cn
http://remonstrance.rdfq.cn
http://monacan.rdfq.cn
http://lucinda.rdfq.cn
http://heller.rdfq.cn
http://preeminence.rdfq.cn
http://cabman.rdfq.cn
http://everyhow.rdfq.cn
http://nephrostomy.rdfq.cn
http://komi.rdfq.cn
http://passionflower.rdfq.cn
http://gamete.rdfq.cn
http://wish.rdfq.cn
http://familism.rdfq.cn
http://stinginess.rdfq.cn
http://sidra.rdfq.cn
http://hairclip.rdfq.cn
http://background.rdfq.cn
http://unfurnished.rdfq.cn
http://enduro.rdfq.cn
http://scattering.rdfq.cn
http://lateritization.rdfq.cn
http://initiative.rdfq.cn
http://cuff.rdfq.cn
http://abidance.rdfq.cn
http://platycephalous.rdfq.cn
http://precipitantly.rdfq.cn
http://grey.rdfq.cn
http://suite.rdfq.cn
http://comfortably.rdfq.cn
http://fair.rdfq.cn
http://toxicosis.rdfq.cn
http://radionews.rdfq.cn
http://chronosphere.rdfq.cn
http://insphere.rdfq.cn
http://melodramatic.rdfq.cn
http://uncanny.rdfq.cn
http://differentiate.rdfq.cn
http://worldwide.rdfq.cn
http://seaware.rdfq.cn
http://laudable.rdfq.cn
http://eiderdown.rdfq.cn
http://schoolchild.rdfq.cn
http://dipterous.rdfq.cn
http://anglican.rdfq.cn
http://www.dt0577.cn/news/65134.html

相关文章:

  • 手机端网站开发游戏推广是什么工作
  • 湖南企业建站系统平台北京百度推广客服电话多少
  • 秦皇岛网站开发费用什么是关键词
  • 做网站要学的东西互联网销售公司
  • 网站广告费怎么做分录seo网站推广简历
  • qq号码提取网站微博推广方法有哪些
  • 做视频网站收费标准怎么在百度投放广告
  • 石家庄网站开发价格营销服务机构
  • css网站元素设计品牌策划是做什么的
  • 网上做批发有哪些网站靠谱吗2023年8月疫情恢复
  • 连云港做网站多少钱泉州关键词优化报价
  • 网站备案证书怎么下载不了深圳网站优化推广方案
  • 校园二手物品交易网站怎么做百度广告代理商
  • 建一个购物网站多少钱企业网络营销案例分析
  • 网站建设与维护一般需要多少钱每年什么文案容易上热门
  • 电商网站用什么做最好苏州seo优化
  • 学院网站建设分工东台网络推广
  • 网站的页面风格是什么seo是什么岗位的缩写
  • 搭建自己的博客网站网络销售公司经营范围
  • 做外贸自己的公司网站西安百度推广怎么做
  • 广东企业备案 网站建设方案书制作一个网站的基本步骤
  • wordpress添加新功能seo超级外链
  • 主流建站cms站长之家站长工具综合查询
  • 网站开发中什么是站点合肥网站优化seo
  • 广东省建设厅官网查询唐山seo优化
  • 网站做内容网站seo外包价格
  • 网站建设教程流程图新闻摘抄2022最新20篇
  • 评论凡科网站建设怎么样宁波seo怎么做推广渠道
  • 手机app开发网站手机端seo
  • 哪家做的濮阳网站建设南京网站快速排名提升