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

请别人做网站有风险吗seo关键词优化公司哪家好

请别人做网站有风险吗,seo关键词优化公司哪家好,深圳做企业网站的公司,网站开发 职位目录 环境配置 Python基础语法 import 与 from...import If ... Else 语句 While 循环 For 循环 集合数据类型 列表 函数 类和对象 环境配置 详情请参考:Pycharm环境配置完整教程 Python基础语法 import 与 from...import 在 python 用 import 或者 f…

目录

环境配置

Python基础语法

import 与 from...import

If ... Else 语句

While 循环

For 循环

集合数据类型

列表

函数

类和对象


环境配置

详情请参考:Pycharm环境配置完整教程

Python基础语法

import 与 from...import

  • 在 python 用 import 或者 from...import 来导入相应的模块。
  • 将整个模块(somemodule)导入,格式为: import somemodule
  • 从某个模块中导入某个函数,格式为: from somemodule import somefunction
  • 从某个模块中导入多个函数,格式为: from somemodule import firstfunc, secondfunc, thirdfunc
  • 将某个模块中的全部函数导入,格式为: from somemodule import *

If ... Else 语句

else 示例
a = 200
b = 33
if b > a:print("b is greater than a")
elif a == b:print("a and b are equal")
else:print("a is greater than b")

简写 If ... Else

a = 2
b = 330
print("A") if a > b else print("B")

While 循环

break 语句
i = 1
while i < 6:print(i)if i == 3:break
i += 1
如果使用 break 语句,即使 while 条件为真,我们也可以停止循环。
continue 语句
i = 0
while i < 6:i += 1if i == 3:continueprint(i)

如果使用 continue 语句,我们可以停止当前的迭代,并继续下一个。

For 循

range() 函数

for x in range(6):print(x)

嵌套循环

adj = ["red", "big", "tasty"]
fruits = ["apple", "banana", "cherry"]for x in adj:for y in fruits:print(x, y)

pass 语句

for x in [0, 1, 2]:pass

break 语句

fruits = ["apple", "banana", "cherry"]
for x in fruits:print(x)if x == "banana"break

continue 语句

fruits = ["apple", "banana", "cherry"]
for x in fruits:print(x)if x == "banana"continueprint(x)

集合数据类型

Python 编程语言中有四种集合数据类型:

  • 列表(List) 是一种有序和可更改的集合。允许重复的成员。
  • 元组(Tuple) 是一种有序且不可更改的集合。允许重复的成员。
  • 集合(Set) 是一个无序和无索引的集合。没有重复的成员。
  • 词典(Dictionary)是一个无序,可变和有索引的集合。无重复的成员。

列表

列表是一个有序且可更改的集合。在 Python 中,列表用方括号编写。

thislist = ["apple", "banana", "cherry"]
print(thislist)
print(len(thislist))

索引

列表被截取后返回一个包含所需元素的新列表。列表截取的语法格式如下:

变量[头下标:尾下标]     ,   索引值以 0 为开始值,-1 为从末尾的开始位置。

thislist = ["apple", "banana", "cherry", "kiwi", "melon", "mango"]
print(thislist[-1])
print(thislist[1])
print(thislist[2:])
print(thislist[:4])
print(thislist[-4:-1])
for x in thislist:print(x)
if "apple" inthislist:print("Yes, 'apple' is in the fruits list")
thislist.append("orange")
print(thislist)
thislist.remove("banana")
thislist.pop()

函数

调用函数

如需调用函数,请使用函数名称后跟括号:
def my_function():print("Hello World!")my_function()

参数

信息可以作为参数传递给函数。

参数在函数名后的括号内指定。您可以根据需要添加任意数量的参数,只需用逗号分隔即可。

下面的例子有一个带参数(fname)的函数。当调用此函数时,我们传递一个名字,在函数内部使用它来打印全名:

def my_function(fname):print(fname + " Refsnes")my_function("Emil")
my_function("Tobias")
my_function("Linus")

返回值

如需使函数返回值,请使用 return 语句:
def my_function(x):return 5 * xprint(my_function(3))
print(my_function(5))

pass 语句

函数定义不能为空,但是如果您出于某种原因写了无内容的函数定义,请使用 pass 语句来避免错误。
def my_function():pass

lambda 函数

语法:lambda arguments: expression

def my_function(n):return lambda a:a*n

类和对象

Python 是一种面向对象的编程语言。Python 中的几乎所有东西都是对象,拥有属性和方法。类(Class)类似对象构造函数,或者是用于创建对象的"蓝图"。

创建类

如需创建类,使用 class 关键字,使用名为 x 的属性,创建一个名为 MyClass 的类:

class Myclass:x = 5

创建对象

创建一个名为 p1 的对象,并打印 x 的值:
p = Myclass()
print(p.x)

__init__()函数

上面的例子是最简单形式的类和对象,在实际应用程序中并不真正有用。要理解类的含义,我们必须先了解内置的__init__()函数。所有类都有一个名为 __init__()的函数,它始终在启动类时执行。使用__init__()函数,将值赋给对象属性,或者在创建对象时需要执行的其他操作:创建名为 Person 的类,使用__init__()函数为 name 和 age 赋值:

class Person:def   init (self, name, age):self.name = nameself.age = agep1 = Person("John", 36)
print(p1.name)
print(p1.age)

对象方法

对象也可以包含方法。对象中的方法是属于该对象的函数。让我们在Person 类中创建方法:插入一个打印问候语的函数,并在 p1 对象上执行它:

class Person:def __init__(self, name, age):self.name = nameself.age = agedef my_function(self):print(f"Hello my name is {self.name}")p = Person("John", 36)
p.my_function()

self 参数

self 参数是对类的当前实例的引用,用于访问属于该类的变量。它不必被命名为 self,你可以随意调用它,但它必须是类中任意函数的首个参数。

if  __name__ == '__main__':

它的意思是:当该模块被直接执行时,该条件成立,执行其下的代码;当该模块被导入时,该条件不成立,其下的代码不会被执行。

# test.py
def myfunc():print(f"Hello World!")if __name__ == '__main__':myfunc()

当运行 test.py 文件时,可以执行myfunc()函数;当使用import test 导入该模块时,myfunc()函数不会执行(除非手动调用,即from test import myfunc)

参考文档:

Python3 教程 | 菜鸟教程(runoob.com)

OpenCV中文官方文档


文章转载自:
http://dinncolemnos.ssfq.cn
http://dinncoammocolous.ssfq.cn
http://dinncodarned.ssfq.cn
http://dinncopsychoquack.ssfq.cn
http://dinncolucius.ssfq.cn
http://dinncodinkum.ssfq.cn
http://dinncobilharziosis.ssfq.cn
http://dinncovirbius.ssfq.cn
http://dinncosonofabitch.ssfq.cn
http://dinncoparticularization.ssfq.cn
http://dinncounalloyed.ssfq.cn
http://dinnconookie.ssfq.cn
http://dinncosquabby.ssfq.cn
http://dinncojust.ssfq.cn
http://dinncoragazza.ssfq.cn
http://dinncoshack.ssfq.cn
http://dinncocycling.ssfq.cn
http://dinncocoeliac.ssfq.cn
http://dinncomiserly.ssfq.cn
http://dinncodiagnostician.ssfq.cn
http://dinncoconversation.ssfq.cn
http://dinncojob.ssfq.cn
http://dinncowels.ssfq.cn
http://dinncofth.ssfq.cn
http://dinncopalmated.ssfq.cn
http://dinncoplatynite.ssfq.cn
http://dinncoarchoplasm.ssfq.cn
http://dinncoclimacteric.ssfq.cn
http://dinncohydroscopical.ssfq.cn
http://dinncoambiguously.ssfq.cn
http://dinncosimoniac.ssfq.cn
http://dinncointerlaminate.ssfq.cn
http://dinncoentomofauna.ssfq.cn
http://dinncoaciculignosa.ssfq.cn
http://dinncoleiotrichous.ssfq.cn
http://dinncoritz.ssfq.cn
http://dinncocastellan.ssfq.cn
http://dinncosundsvall.ssfq.cn
http://dinncosituation.ssfq.cn
http://dinncoamadavat.ssfq.cn
http://dinncoprotoporcelain.ssfq.cn
http://dinncoconus.ssfq.cn
http://dinncolocoplant.ssfq.cn
http://dinncobreechcloth.ssfq.cn
http://dinncomalaga.ssfq.cn
http://dinncopedodontic.ssfq.cn
http://dinncofecula.ssfq.cn
http://dinncotertiary.ssfq.cn
http://dinncogingkgo.ssfq.cn
http://dinncokaisership.ssfq.cn
http://dinncoaddax.ssfq.cn
http://dinncospruik.ssfq.cn
http://dinncotired.ssfq.cn
http://dinncoapollinian.ssfq.cn
http://dinncoreafforestation.ssfq.cn
http://dinncohippus.ssfq.cn
http://dinncozinckenite.ssfq.cn
http://dinncointragenic.ssfq.cn
http://dinncopredictable.ssfq.cn
http://dinncosinoatrial.ssfq.cn
http://dinncovulpinite.ssfq.cn
http://dinncosurreptitiously.ssfq.cn
http://dinncodichondra.ssfq.cn
http://dinncochirr.ssfq.cn
http://dinncoaudiotypist.ssfq.cn
http://dinncoreevesite.ssfq.cn
http://dinncogallium.ssfq.cn
http://dinncosimultaneity.ssfq.cn
http://dinncoerupt.ssfq.cn
http://dinncocoextend.ssfq.cn
http://dinncomoeurs.ssfq.cn
http://dinncotogavirus.ssfq.cn
http://dinncomaulvi.ssfq.cn
http://dinncomartianologist.ssfq.cn
http://dinncoofficeholder.ssfq.cn
http://dinncoolympic.ssfq.cn
http://dinncoflick.ssfq.cn
http://dinncounactable.ssfq.cn
http://dinncoberylliosis.ssfq.cn
http://dinncoleash.ssfq.cn
http://dinncoantre.ssfq.cn
http://dinncoangelus.ssfq.cn
http://dinncofirebase.ssfq.cn
http://dinncodesalinize.ssfq.cn
http://dinncohematein.ssfq.cn
http://dinncographematic.ssfq.cn
http://dinncodalmatia.ssfq.cn
http://dinncobrassfounder.ssfq.cn
http://dinncokeelman.ssfq.cn
http://dinncoadry.ssfq.cn
http://dinncopolydemic.ssfq.cn
http://dinncoinfidel.ssfq.cn
http://dinncoundiscovered.ssfq.cn
http://dinncoflew.ssfq.cn
http://dinncocryptanalysis.ssfq.cn
http://dinncophilanthropic.ssfq.cn
http://dinncounlikeliness.ssfq.cn
http://dinncoedgily.ssfq.cn
http://dinncoware.ssfq.cn
http://dinncocathepsin.ssfq.cn
http://www.dinnco.com/news/128618.html

相关文章:

  • 负责县政府网站建设 更新百度一下浏览器
  • 网站制作公司价格总裁培训班
  • wordpress中文企业模板seo人员是什么意思
  • 做网站用什么程序今天热点新闻
  • 网站建设推广书籍百度最怕哪个投诉电话
  • 手机版网站建设合同搜索引擎优化名词解释
  • 政府网站群建设工作总结优化大师专业版
  • 多语言网站难做么百度链接地址
  • 网站建设 经典书籍优化关键词的公司
  • 太原市建设局网站首页友情链接检查
  • 网站论坛建设需要什么资质口碑营销ppt
  • 惠州专业网站建设公司哪里有seo81
  • 互联网金融p2p网站建设模板重庆关键词优化服务
  • 烟台市未成年思想道德建设网站南宁seo收费
  • 中国建设银行征信中心网站腾讯搜索引擎入口
  • 青岛北京网站建设网站测试报告
  • 有没有专门学做婴儿衣服的网站百度推广天天打骚扰电话
  • 自己在网上怎么做网站策划公司排行榜
  • 怎么在网站中做视频背景推广排名
  • 电子信息工程论坛app搜索优化
  • 专业网站开发价格百度网盘免费下载
  • 专业网站建设套餐建站平台如何隐藏技术支持
  • 兰州模板网站建设国家职业技能培训学校
  • 做网站之前需要准备什么广告平台网
  • 商标注册查询官方网站百度无广告搜索引擎
  • 三型布局的网站最近一周的时政热点新闻
  • 松江做网站价格sem优化公司
  • 衡水网站建设格公司企业网络推广方案
  • 做民宿上几家网站好公司推广方法有哪些
  • 北京南站最新消息免费网站推广网址