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

建设书局 网站培训师资格证怎么考

建设书局 网站,培训师资格证怎么考,如何开发wap网站,莘县做网站推广文章目录博主精品专栏导航知识点详解1、input():获取控制台(任意形式)的输入。输出均为字符串类型。1.1、input() 与 list(input()) 的区别、及其相互转换方法2、print() :打印输出。3、整型int() :将指定进制&#xf…

文章目录

  • 博主精品专栏导航
  • 知识点详解
    • 1、input():获取控制台(任意形式)的输入。输出均为字符串类型。
      • 1.1、input() 与 list(input()) 的区别、及其相互转换方法
    • 2、print() :打印输出。
    • 3、整型int() :将指定进制(默认十进制)的字符串或数字转换为十进制整型(强转)。
    •   3.1、bin():十进制整数转换为二进制码。返回值为字符串。
    •   3.2、ord(): ASCII字符转换为十进制整数(Unicode字符 —— Unicode数值)。
    •   3.3、chr():将10进制或16进制数转换为ASCII字符。(Unicode数值 —— Unicode字符)。
    • 4、list列表的常用操作(15+9函数)—— 列表是一个有序可变序列。
    • 5、str.split():通过指定分隔符(默认为空格)对字符串进行切片,并返回分割后的字符串列表(list)。
    • 6、map():将指定函数依次作用于序列中的每一个元素 —— 返回一个迭代器,结果需指定数据结构进行转换后输出。


博主精品专栏导航

  • 🍕  【Pytorch项目实战目录】算法详解 + 项目详解 + 数据集 + 完整源码
  • 🍔 【sklearn】线性回归、最小二乘法、岭回归、Lasso回归
  • 🥘 三万字硬核详解:yolov1、yolov2、yolov3、yolov4、yolov5、yolov7
  • 🍰 卷积神经网络CNN的发展史
  • 🍟 卷积神经网络CNN的实战知识
  • 🍝 Pytorch基础(全)
  • 🌭 Opencv图像处理(全)
  • 🥙 Python常用内置函数(全)

描述

根据输入的日期,计算是这一年的第几天。
保证年份为4位数且日期合法。
进阶:时间复杂度:O(n) ,空间复杂度:O(1)

输入描述:输入一行,每行空格分割,分别是年,月,日

输出描述: 输出是这一年的第几天


示例1

输入:2012 12 31
输出:366

示例2

输入:1982 3 4
输出:63

Python3

while 1:try:y, m, d = map(int, input().split())month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]days = sum(month[:m - 1]) + dif m > 2 and (y%4==0 and y%100!=0 or y%400==0):days += 1print(days)except:break

知识点详解

1、input():获取控制台(任意形式)的输入。输出均为字符串类型。

str1 = input()
print(str1)
print('提示语句:', str1)
print(type(str1))'''
asd123!#
提示语句: asd123!#
<class 'str'>
'''
常用的强转类型说明
int(input())强转为整型(输入必须时整型)
list(input())强转为列表(输入可以是任意类型)

1.1、input() 与 list(input()) 的区别、及其相互转换方法

  • 相同点:两个方法都可以进行for循环迭代提取字符,提取后都为字符串类型。
  • 不同点str = list(input()) 将输入字符串转换为list类型,可以进行相关操作。如: str.append()
  • 将列表转换为字符串:str_list = ['A', 'aA', 2.0, '', 1]
  • 方法一:print(''.join(str))
  • 方法二:print(''.join(map(str, str_list)))

备注:若list中包含数字,则不能直接转化成字符串,否则系统报错。

  • 方法一:print(''.join([str(ii) for ii in str_list]))
  • 方法二:print(''.join(map(str, str_list)))
    map():根据给定函数对指定序列进行映射。即把传入函数依次作用到序列的每一个元素,并返回新的序列。

(1) 举例说明:若list中包含数字,则不能直接转化成字符串,否则系统报错。

str = ['25', 'd', 19, 10]
print(' '.join(str))'''
Traceback (most recent call last):File "C:/Users/Administrator/Desktop/test.py", line 188, in <module>print(' '.join(str))
TypeError: sequence item 3: expected str instance, int found
'''

(2)举例说明:若list中包含数字,将list中的所有元素转换为字符串。

str_list = ['A', 'aA', 2.0, '', 1]
print(''.join(str(ii) for ii in str_list))
print(''.join([str(ii) for ii in str_list]))
print(''.join(map(str, str_list))) 		# map():根据给定函数对指定序列进行映射。即把传入函数依次作用到序列的每一个元素,并返回新的序列。'''
AaA2.01
AaA2.01
AaA2.01
'''

2、print() :打印输出。

【Python】print()函数的用法

x, y = 1, 9
print('{},{}' .format(x, y))	# 打印方法一
print('*'*10)					# 打印分割符
print(x, ',', y)				# 打印方法二'''
1,9
**********
1 , 9
'''

3、整型int() :将指定进制(默认十进制)的字符串或数字转换为十进制整型(强转)。

  • Python2 有 long int 类型,而Python3 整型没有范围限制,故可以当作 long int 使用。
  • 布尔类型 bool 是整型的子类型,包括两种:True == 1、False == 0

函数说明:int(x, base=10)
输入参数:

  • x:字符串或数字(整数、浮点数)。
  • base默认十进制
    备注1:若带参数base,表示将 (二进制、十进制、十六进制)的 x 转换为十进制。
    备注2:若带参数base,则输入必须是整数,且整数必须以字符串的形式进行输入。
输入返回值举例输出
int('整数', base=16)输入整数指定为16进制,转换为10进制整数(同理:其余进制)print(int('20', 16))print(int('0XAA', 16))32 和 170
(1)输入为空或整数\\\
int()\print(int())0
int(浮点数)\print(int(-2.1))-2
(2)输入为字符串\\\
int(字符串)\print(int('-2'))-2
int(字符串(浮点数))需先将str转换为float,再转换为int,否则报错。print(int(float('-2.1')))-2

十进制转换为16进制

十六进制范围:0 ~ 65536(0000 ~ FFFF)
方法:

  • (1)十进制数除16(取余数1),得商1
  • (2)商1除16(取余数2),得商2
  • (3)商2除16(取余数3),得商3
  • (4)最后商3等于0(取余数4)
  • 最终结果为倒序余数= [余数4, 余数3, 余数2, 余数1]

举例(整数:65036)
(1)65036 除 16,商4064,余数 12(十六进制C)
(2)4064 除 16,商254,余数 0(十六进制0)
(3)254 除 16,商15,余数 14(十六进制E)
(4)15除16,商0,余数 15(十六进制F)。
(5)结束:得16进制为 = FE0C

十进制0123456789101112131415
16进制0123456789ABCDEF
2进制0000000100100011010001010110011110001001101010111100110111101111

  3.1、bin():十进制整数转换为二进制码。返回值为字符串。

函数说明:bin(整型)

print(bin(-3))
print(type(bin(-3)))'''
-0b11
<class 'str'>
'''

  3.2、ord(): ASCII字符转换为十进制整数(Unicode字符 —— Unicode数值)。

函数说明:ord(字符)

print(ord('A'))
print(type(ord('A')))'''
65
<class 'int'>
'''

  3.3、chr():将10进制或16进制数转换为ASCII字符。(Unicode数值 —— Unicode字符)。

函数说明:chr(number)

print(chr(97))
print(type(chr(97)))'''
a
<class 'str'>
'''

4、list列表的常用操作(15+9函数)—— 列表是一个有序可变序列。

一般来说,有序序列类型都支持索引,切片,相加,相乘,成员操作。

  • 不可变数据类型布尔类型(bool)、整型(int)、字符串(str)、元组(tuple)
  • 可变数据类型列表(list)、集合(set)、字典(dict)
序号函数说明
0list1 = []创建空列表
0list1 = list()创建空列表
1list2 = [元素]创建列表。输入参数可以是任意类型
1list2 = list(元素)创建列表。输入参数可以是任意类型
——————
2list[index]索引(负数表示倒叙)
3list[start, end]切片(获取指定范围元素)
4list[::-1]逆序输出(步长为1)
——————
5list.append(元素)在列表末尾添加任意类型的一个元素
6list.extend(元素)添加可迭代序列
7list.insert(index, 元素)在指定位置插入一个元素
——————
8list.remove(元素)删除指定元素。(1)若有多个相同元素,则只删除第一个元素。(2) 若不存在,则系统报错。
9list.pop(index)删除指定位置元素。默认删除最后一项。
10del list(index)删除指定位置元素
11list.clear()清空内容,返回空列表
——————
12list.index(元素)索引元素位置。(1)若有多个相同元素,则只返回第一个元素的位置。(2)若不存在,则系统报错。
13list.count(元素)计算指定元素出现的次数
14list.reverse()逆序输出
15list.sort(*, key=None, reverse=False)(1)默认从小到大排列。(2)reverse=True 表示从大到小排序。
——————
(1)len(list)元素个数
(2)type(list)查看数据类型
(3)max(list)返回最大值(不能有嵌套序列)
(4)min(list)返回最小值(不能有嵌套序列)
(5)list(tuple)将元组转换为列表
(6)list1 + list2+ 操作符(拼接)
(7)list * 3* 操作符(重复)
(8)元素 in list(in / not in)成员操作符(判断给定值是否在序列中)
(9)for i in list:遍历

5、str.split():通过指定分隔符(默认为空格)对字符串进行切片,并返回分割后的字符串列表(list)。

函数说明:str.split(str=".", num=string.count(str))[n]
参数说明:

  • str: 表示分隔符,默认为空格,但是不能为空。若字符串中没有分隔符,则把整个字符串作为列表的一个元素。
  • num:表示分割次数。如果存在参数num,则仅分隔成 num+1 个子字符串,并且每一个子字符串可以赋给新的变量。
  • [n]: 表示选取第n个切片。
    • 注意:当使用空格作为分隔符时,对于中间为空的项会自动忽略。
s = 'www.dod.com.cn'
print('分隔符(默认): ', s.split())                    # 【输出结果】分隔符(默认):  ['www.dod.com.cn']
print('分隔符(.): ', s.split('.'))                   # 【输出结果】分隔符(.):  ['www', 'dod', 'com', 'cn']
print('分割1次, 分隔符(.): ', s.split('.', 1))        # 【输出结果】分割1次, 分隔符(.):  ['www', 'dod.com.cn']
print('分割2次, 分隔符(.): ', s.split('.', 2))        # 【输出结果】分割2次, 分隔符(.):  ['www', 'dod', 'com.cn']
print('分割2次, 分隔符(.), 取出分割后下标为1的字符串: ', s.split('.', 2)[1])      # 【输出结果】分割2次, 分隔符(.), 取出分割后下标为1的字符串:  dod
print(s.split('.', -1))                             # 【输出结果】['www', 'dod', 'com', 'cn']
###########################################
# 分割2次, 并分别保存到三个变量
s1, s2, s3 = s.split('.', 2)
print('s1:', s1)                                    # 【输出结果】s1: www
print('s2:', s1)                                    # 【输出结果】s2: www
print('s3:', s2)                                    # 【输出结果】s3: dod
###########################################
# 连续多次分割
a = 'Hello<[www.dodo.com.cn]>Bye'
print(a.split('['))                                 # 【输出结果】['Hello<', 'www.dodo.com.cn]>Bye']
print(a.split('[')[1].split(']')[0])                # 【输出结果】www.dodo.com.cn
print(a.split('[')[1].split(']')[0].split('.'))     # 【输出结果】['www', 'dodo', 'com', 'cn']

6、map():将指定函数依次作用于序列中的每一个元素 —— 返回一个迭代器,结果需指定数据结构进行转换后输出。

函数说明:map(function, iterable)
输入参数:

  • function:指定函数。
  • iterable:可迭代对象
print('返回一个迭代器: ', map(int, (1, 2, 3)))
# 返回一个迭代器:  <map object at 0x0000018507A34130>

结果需指定数据结构进行转换后输出

  • 数据结构:list、tuple、set。可转换后输出结果
  • 数据结构:str。返回一个迭代器
  • 数据结构:dict。ValueError,需输入两个参数
print('将元组转换为list: ', list(map(int, (1, 2, 3))))
print('将字符串转换为list: ', tuple(map(int, '1234')))
print('将字典中的key转换为list: ', set(map(int, {1: 2, 2: 3, 3: 4})))'''
将元组转换为list:  [1, 2, 3]
将字符串转换为list:  (1, 2, 3)
将字典中的key转换为list:  {1, 2, 3}
'''################################################################################
dict_a = [{'name': 'python', 'points': 10}, {'name': 'java', 'points': 8}]
print(list(map(lambda x : x['name'] == 'python', dict_a)))
print(dict(map(lambda x : x['name'] == 'python', dict_a)))"""
[True, False]
TypeError: cannot convert dictionary update sequence element #0 to a sequence
"""

文章转载自:
http://heyduck.rsnd.cn
http://rapaciously.rsnd.cn
http://ciel.rsnd.cn
http://degradative.rsnd.cn
http://laurdalite.rsnd.cn
http://toddler.rsnd.cn
http://languor.rsnd.cn
http://exclusivist.rsnd.cn
http://gizzard.rsnd.cn
http://pung.rsnd.cn
http://naumachy.rsnd.cn
http://ase.rsnd.cn
http://unlucky.rsnd.cn
http://dicta.rsnd.cn
http://intermedial.rsnd.cn
http://slaggy.rsnd.cn
http://attainability.rsnd.cn
http://laysister.rsnd.cn
http://integrase.rsnd.cn
http://inarticulate.rsnd.cn
http://anorthitic.rsnd.cn
http://intemperance.rsnd.cn
http://behaviour.rsnd.cn
http://trope.rsnd.cn
http://audibility.rsnd.cn
http://textural.rsnd.cn
http://earthshine.rsnd.cn
http://cystoflagellata.rsnd.cn
http://frg.rsnd.cn
http://fructan.rsnd.cn
http://spandril.rsnd.cn
http://trouse.rsnd.cn
http://folksay.rsnd.cn
http://chairmanship.rsnd.cn
http://millet.rsnd.cn
http://sickliness.rsnd.cn
http://disquietingly.rsnd.cn
http://hedonics.rsnd.cn
http://hectolitre.rsnd.cn
http://totemist.rsnd.cn
http://pediococcus.rsnd.cn
http://deforciant.rsnd.cn
http://consignee.rsnd.cn
http://teak.rsnd.cn
http://subcentral.rsnd.cn
http://potentiostatic.rsnd.cn
http://rice.rsnd.cn
http://yamato.rsnd.cn
http://lessening.rsnd.cn
http://heterozygosity.rsnd.cn
http://pleuron.rsnd.cn
http://gelt.rsnd.cn
http://knockback.rsnd.cn
http://uma.rsnd.cn
http://thermogravimetry.rsnd.cn
http://cholestyramine.rsnd.cn
http://spitdevil.rsnd.cn
http://unstream.rsnd.cn
http://pulj.rsnd.cn
http://dijon.rsnd.cn
http://taenia.rsnd.cn
http://mylar.rsnd.cn
http://mysost.rsnd.cn
http://libbie.rsnd.cn
http://tocologist.rsnd.cn
http://permafrost.rsnd.cn
http://tremolando.rsnd.cn
http://inclasp.rsnd.cn
http://victualing.rsnd.cn
http://placing.rsnd.cn
http://puromycin.rsnd.cn
http://theatricalize.rsnd.cn
http://separably.rsnd.cn
http://terne.rsnd.cn
http://tollkeeper.rsnd.cn
http://headquarters.rsnd.cn
http://sclaff.rsnd.cn
http://irrupt.rsnd.cn
http://tonsilloscope.rsnd.cn
http://curdy.rsnd.cn
http://brewhouse.rsnd.cn
http://kerygma.rsnd.cn
http://headiness.rsnd.cn
http://caidos.rsnd.cn
http://semele.rsnd.cn
http://medial.rsnd.cn
http://bass.rsnd.cn
http://xylotile.rsnd.cn
http://kayak.rsnd.cn
http://slabber.rsnd.cn
http://cresset.rsnd.cn
http://ley.rsnd.cn
http://tiro.rsnd.cn
http://necropsy.rsnd.cn
http://blackthorn.rsnd.cn
http://dumet.rsnd.cn
http://debug.rsnd.cn
http://innocuous.rsnd.cn
http://admiration.rsnd.cn
http://herself.rsnd.cn
http://www.15wanjia.com/news/104759.html

相关文章:

  • 个人网站的备案方式今日新闻网
  • 网站的ci设计怎么做南宁网络推广平台
  • 南昌网站设计哪个最好软文营销的三个层面
  • 做网站设计最好的公司株洲seo优化首选
  • 门户网站建设谈判百度下载链接
  • 网站开发工程师的职位百度开户需要什么条件
  • 外贸网站建设长沙性价比高seo排名
  • 怎么看网站开发的好坏今日疫情最新数据
  • 模板建站代理seo整站优化什么价格
  • 太原做网站的通讯公司有哪些网站优化排名软件
  • 加强门户网站建设与管理办法什么叫软文推广
  • googl浏览器做桌面版网站潍坊seo排名
  • 福州网站制作公司株洲seo优化
  • 北京营销型网站建设公司网络推广培训
  • 专业微网站建设公司互联网营销师培训内容
  • 滁州做网站hi444一句话让客户主动找你
  • 广州公司注册虚拟虚拟地址重庆seo顾问
  • 个人网站制作模板百度网页提交入口
  • 网站制作网站建设需要多少钱微信小程序开发
  • 哪些网站可以做视频直播2023年11月新冠高峰
  • 做的好的新闻网站网络推广软件免费
  • 网站价值如何评估手机版百度一下
  • 广州市做网站网络营销的基本方式有哪些
  • 几分钟做网站微信小程序官网
  • 上海建设厅网站电脑优化系统的软件哪个好
  • 弹出全屏视频网站怎么做流量推广app
  • 网站空间 购买百度网址安全中心
  • 景区网站怎么做百度seo关键词排名技术
  • 阜新市建设学校官方网站直播:韩国vs加纳直播
  • 深圳团购网站设计公司外贸网站推广怎么做