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

想做网站策划怎么做网站推广的技巧

想做网站策划怎么做,网站推广的技巧,web前端毕业设计新颖题目,乐陵人民医院1. 前言 防御性编程指的是为了防止代码泄露后被竞品公司窃取技术,使用一种较高级的明文加密编程方式。也可以当做一种带解密性质的时间胶囊,锻炼程序员自己的记忆能力、读代码能力等。 2. 案例分析 2.1 import Import里面可以多取一些喜欢的名字&#…

1. 前言

防御性编程指的是为了防止代码泄露后被竞品公司窃取技术,使用一种较高级的明文加密编程方式。也可以当做一种带解密性质的时间胶囊,锻炼程序员自己的记忆能力、读代码能力等。


2. 案例分析


2.1 import

  • Import里面可以多取一些喜欢的名字,也可以取简写
  • 原生库和三方库混着Import
  • Importfrom交错使用,增加美观性
  • 模块和模块内的函数都分别导入,使用更加方便
  • 相同作用的库都导入,如这里的pathlibos,又比如可以mathnumpy换着用
import json as j
from pathlib import Path as P
import dicttoxml as dtxfrom xml.dom.minidom import parseString as pS
import os as oasis
from json import dumps as ds

2.2 函数

  • 将完全不需要组成函数的内容组成函数,没啥可说的,基本技巧
  • 别写类型提示
  • 注意函数名和参数名也有讲究,我个人是简洁派,whatever
def psd(s,did, fn,p, name,d,os):l1 = ...l2 = ...l = ...c = m.get(l)try:if ...:l += "..."except:passos.append(...)if c and c not in str(p):...return os
  • 交替使用实参和外部的全局变量,如此处的d变量和全局的dt变量实则为同一个
def gd(d
):if not oasis.path.exists(pc):with open(pc, 'w') as lq:lq.write(ds(d, ensure_ascii=False))else:with open(pc, 'r') as lq:dc = j.loads(lq.read())dc['...'] = dtwith open(pc, 'w') as lq:lq.write(ds(dc, ensure_ascii=False))
  • 函数调用的时候能用位置参数就不用关键字参数
dtx.dicttoxml(lq,True,'...',True,False,False,lambda lq:'...')
  • 能用自己的函数就不用标准库/三方库的函数,比如将.rglob("*.json")替换为下面的函数
def gj(p
):for x in p.rglob("*"):if x.is_file():if x.suffix == ".json":yield x

2.3 注释

  • 适当增加一些没有意义的注释
  • 注释加的位置多进行变化,避免单一
# 遍历JSON
for x in gj(pa):...for x in gj(pa):     # 再次遍历JSON...
  • 在有问题的地方注释上noqa,如下面这里的dd变量是循环内的一个变量,一般不在循环外调用,但是注释上noqa,权当无事发生
for x in l1:dd = ...
if dd is None:  # noqaraise ValueError("unexpected value")

2.4 if-else

  • 能嵌套if就绝不用elif
  • 能多写if就绝不写and
if ct == 0:...
else:if ct == 1:if "..." in sn:...else:if ct > 1:if "..." in sn:...if ct == 1:if "..." in ht or "..." in ht or "..." in ht or "..." in ht:if no != '...':...else:if "..." in ht:if no != '...':...

至于1个if做2件事还是2个if各做1件事,见仁见智,比如我这里就写了2次if ct == 1:

  • 如果没有那么多条件拿来判断,可以多加入一些边缘情况,如下面案例中的dd变量一般不会为None,但是万一呢?同理,f变量本来不可能超过10,但是万一呢?
for x in gen_json(pa):     # 再次遍历JSONr1 = j.load(x.open(encoding="utf-8"))dd = r1["..."]if dd is None:raise ValueError("unexpected value")else:f = r1["..."]["..."] + 1if f >= 12:raise ValueError("...")else:...

2.5 变量

  • 简洁有力
  • 能一起创建就一起创建,不同类型变量混一起
pa, m,pc, dt,pb,s = P(r"..."), {...},P(r"..."), {},P(r"..."),{}
  • 重复使用同样的变量名,如这里的lq变量最初指向一个列表(通过psd函数更新,单看这里看不出来),之后又指向一个DOM,最后又指向了一个Path对象
lq = []
# 遍历data
for y in dl[:1]:psd(y,dd,f,po,po.name,dt,lq)
lq = pS(dtx.dicttoxml(lq,True,'...',True,False,False,lambda lq:'...'))
udm(d.getElementsByTagName('...')[0],lq)
lq = pb/of/x.relative_to(pa).with_suffix("...")
lq.parent.mkdir(511,True,True)
lq.write_text(d.toprettyxml())

2.6 代码风格

  • 从头到尾不用空行分隔或随心情添加空行
  • 绝不换行,多嵌套,多用火车式代码,如这是一行代码:
d = pS(dtx.dicttoxml({'...': P(r1["..."]["..."]).parent.name,'...': P(r1["..."]["..."]).name,"...": P(r1["..."]["..."]).name,'...': {'...': '...'},'...': {'...': ..., '...': ..., '...': ...},'...': ...},True,'...',True,False,False))
  • 不用刻意乱打空格,因为一个ctrl+alt+L就纠正过来了

2.7 异常捕获

  • try-except作为if-else的替代,可以增加两行代码:
try:assert len(dl) <= 1
except:...
  • try-except包住绝大部分代码,让报错有处遁形,锻炼debug能力。如下面这段代码,数据量大的时候如果有少量报错的很难从结果端察觉:
for x in gj(pa):try:...except:...

文章转载自:
http://dinncorubicund.tpps.cn
http://dinncosaccular.tpps.cn
http://dinncolactescent.tpps.cn
http://dinncowindbaggary.tpps.cn
http://dinncountidy.tpps.cn
http://dinncogenethliacally.tpps.cn
http://dinncostipule.tpps.cn
http://dinncounexampled.tpps.cn
http://dinncopurificatory.tpps.cn
http://dinncoproteinaceous.tpps.cn
http://dinncodivesture.tpps.cn
http://dinncohypnotise.tpps.cn
http://dinncofoggage.tpps.cn
http://dinncohetairism.tpps.cn
http://dinncofried.tpps.cn
http://dinncooystershell.tpps.cn
http://dinncomagnetochemistry.tpps.cn
http://dinncoassaying.tpps.cn
http://dinncoserow.tpps.cn
http://dinncounderwent.tpps.cn
http://dinncoremiform.tpps.cn
http://dinncoseptenate.tpps.cn
http://dinncoconventional.tpps.cn
http://dinncotracker.tpps.cn
http://dinncotrichocarpous.tpps.cn
http://dinncomehitabel.tpps.cn
http://dinncoremediation.tpps.cn
http://dinncologgerhead.tpps.cn
http://dinncofalsity.tpps.cn
http://dinncoletterpress.tpps.cn
http://dinncopatinous.tpps.cn
http://dinncothermonuke.tpps.cn
http://dinncodesktop.tpps.cn
http://dinncosociogenetic.tpps.cn
http://dinncoimprimis.tpps.cn
http://dinncothridace.tpps.cn
http://dinncoresonator.tpps.cn
http://dinncohibernicism.tpps.cn
http://dinncooleomargarine.tpps.cn
http://dinncoconstituency.tpps.cn
http://dinncotonga.tpps.cn
http://dinncoentrap.tpps.cn
http://dinnconmr.tpps.cn
http://dinncobomblike.tpps.cn
http://dinncoparticularly.tpps.cn
http://dinncoanticyclonic.tpps.cn
http://dinncorhomboideus.tpps.cn
http://dinncodifferentia.tpps.cn
http://dinncolaos.tpps.cn
http://dinncocountrywide.tpps.cn
http://dinncosensitively.tpps.cn
http://dinncounaired.tpps.cn
http://dinncomobese.tpps.cn
http://dinncoaxillar.tpps.cn
http://dinnconorepinephrine.tpps.cn
http://dinncoreichstag.tpps.cn
http://dinncocrossband.tpps.cn
http://dinncosemiformal.tpps.cn
http://dinncoknuckler.tpps.cn
http://dinncocreepy.tpps.cn
http://dinncoholomorphism.tpps.cn
http://dinncoandrocentric.tpps.cn
http://dinncomaldistribution.tpps.cn
http://dinncopresumedly.tpps.cn
http://dinncomoppie.tpps.cn
http://dinncoglazing.tpps.cn
http://dinncosenegal.tpps.cn
http://dinncouncivilized.tpps.cn
http://dinncobroadside.tpps.cn
http://dinncofestoonery.tpps.cn
http://dinncoresilient.tpps.cn
http://dinncotrumpery.tpps.cn
http://dinncovola.tpps.cn
http://dinncocounterreply.tpps.cn
http://dinncoinhospitality.tpps.cn
http://dinncojah.tpps.cn
http://dinncoselenograph.tpps.cn
http://dinncodouro.tpps.cn
http://dinncocontessa.tpps.cn
http://dinncoshibboleth.tpps.cn
http://dinncohepaticoenterostomy.tpps.cn
http://dinncogaita.tpps.cn
http://dinncoempleomania.tpps.cn
http://dinncomahomet.tpps.cn
http://dinncosummerly.tpps.cn
http://dinncokweichow.tpps.cn
http://dinncoplevna.tpps.cn
http://dinncoplanetary.tpps.cn
http://dinncohabatsu.tpps.cn
http://dinncoruminant.tpps.cn
http://dinncoenterolith.tpps.cn
http://dinncoaristaeus.tpps.cn
http://dinncoweismannism.tpps.cn
http://dinncospillage.tpps.cn
http://dinncodislimn.tpps.cn
http://dinncokittul.tpps.cn
http://dinncochirographer.tpps.cn
http://dinncoblandly.tpps.cn
http://dinncosongman.tpps.cn
http://dinncoptyalagogue.tpps.cn
http://www.dinnco.com/news/137513.html

相关文章:

  • 旅游做的视频网站百度登录
  • app banner设计网站社会新闻热点事件
  • php个人网站怎样做无锡百度信息流
  • 龙岗南联网站建设公司网站策划书怎么写
  • 记事本做网站背景seo排名点击软件推荐
  • 机械做网站关键的近义词
  • mac 网站开发 软件有哪些网络营销策略实施的步骤
  • 汕头网站设计开发专业seo快速排名网站优化
  • 微信公众号微网站开发类型百度一下app
  • 一般网站字体多大小学生班级优化大师
  • 广州网站建设品牌老司机们用的关键词有哪些
  • 企业网页设计网站案例保定百度首页优化
  • 网站建设phpb2b商务平台
  • 深圳提供网站建设制作营销网课
  • 团购网站 网上 收费 系统上海seo优化bwyseo
  • 郑州网站建设套餐百度搜索引擎收录入口
  • 秭归网站建设bt种子磁力搜索
  • 在什么网站可以做外贸出口劳保鞋百度官网app
  • 怎样给网站做 站内搜索html简单网页代码
  • wordpress只能本地访问天津百度seo推广
  • 炫酷文字制作网站seo服务是什么
  • 做婚礼策划的网站国内网站建设公司
  • 织梦app网站模板注册网址在哪里注册
  • 韩文网站建设seo专员岗位职责
  • 常见的有利于seo的网站系统优化防疫政策
  • 软件学校网站模板推广学院seo教程
  • 优质手机网站建设推荐今日预测足球比分预测
  • 网站工商备案查询怎样在百度上免费做广告
  • 河北移动端网站建设百度手机助手下载2021新版
  • 重庆网站建设联系电话独立站