9月 152020
 

已使用函数的简单总结

print()
print是一个放入对象就能将结果打印的函数
input()
input是一个可以让用户输入信息的函数
len()
len是一个可以测量对象长度的函数
int()
int是一个可以将字符串类型的数字转换成整数类型的函数

Python 3.8内建函数列表

https://docs.python.org/3/library/functions.html
+---------------+-------------+--------------+--------------+----------------+
| abs()         | delattr()   | hash()       | memoryview() | set()          |
+---------------+-------------+--------------+--------------+----------------+
| all()         | dict()      | help()       | min()        | setattr()      |
+---------------+-------------+--------------+--------------+----------------+
| any()         | dir()       | hex()        | next()       | slice()        |
+---------------+-------------+--------------+--------------+----------------+
| ascii()       | divmod()    | id()         | object()     | sorted()       |
+---------------+-------------+--------------+--------------+----------------+
| bin()         | enumerate() | input()      | oct()        | staticmethod() |
+---------------+-------------+--------------+--------------+----------------+
| bool()        | eval()      | int()        | open()       | str()          |
+---------------+-------------+--------------+--------------+----------------+
| breakpoint()  | exec()      | isinstance() | ord()        | sum()          |
+---------------+-------------+--------------+--------------+----------------+
| bytearray()   | filter()    | issubclass() | pow()        | super()        |
+---------------+-------------+--------------+--------------+----------------+
| bytes()       | float()     | iter()       | print()      | tuple()        |
+---------------+-------------+--------------+--------------+----------------+
| callable()    | format()    | len()        | property()   | type()         |
+---------------+-------------+--------------+--------------+----------------+
| chr()         | frozenset() | list()       | range()      | vars()         |
+---------------+-------------+--------------+--------------+----------------+
| classmethod() | getattr()   | locals()     | repr()       | zip()          |
+---------------+-------------+--------------+--------------+----------------+
| compile()     | globals()   | map()        | reversed()   | __import__()   |
+---------------+-------------+--------------+--------------+----------------+
| complex()     | hasattr()   | max()        | round()      |                |
+---------------+-------------+--------------+--------------+----------------+
9月 152020
 
#字符串格式化符,不同写法,效果相同
print('{} a word she can get what she {} for.'.format('With','came'))
#对字符串中的“空”使用.format()处理
print('{preposition} a word she can get what she {verb} for'.format(preposition = 'With',verb = 'came'))
#字符串中的“空”值可以是变量
print('{0} a word she can get what she {1} for.'.format('With','came'))
#字符穿中的“空”值按顺序填入
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python38/python.exe c:/Users/harveymei/hello.py
With a word she can get what she came for.
With a word she can get what she came for
With a word she can get what she came for.
PS C:\Users\harveymei>
#字符串格式化符
city = input("write down the name of city:")
#通过用户输出传入变量,使用变量值作为字符串中的填空值
url = "http://apistore.baidu.com/microservice/weather?citypinyin={}".format(city)
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python38/python.exe c:/Users/harveymei/hello.py
write down the name of city:
PS C:\Users\harveymei> 
9月 152020
 

【物品编码】即赋予物品的代码。【代码】则是表示特定事物(如某一物品)的一个或一组字符。
【解码】是将代码还原为物品信息的过程,是编码的逆运算。
将代码赋予载体的过程就是【“标示”】的过程,同样从载体读取信息的过程也就是【“识别”】的过程。

【物品】应该是可标识的,可量化的,且可被用于编码标识,信息采集,网络传输的对象,它包括有形的物理实体,无形的服务产品以及虚拟产品。
【物品】不仅是实体物,也可以是虚拟物。因此选用事物来表达它是一种客观存在的含义,“事”标识虚拟物,“物”标识实体物。
【物品】是进入了经济和社会活动的物。没有进入经济和社会活动的存在是”物“而非”物品“。

【产品】是物品,既包括实体的物品,也包括虚拟的物品,是物品在社会和经济活动中的具体表现形式。
【商品】是满足人们某种需要并用于交换的产品。

国家标准分类与编码通用术语GB/T 10113-2003中对【编码】的定义是给事物或概念赋予代码的过程。

【物品编码分类】是一个动作。
【物品信息分类】是指根据事物的特征将信息按照一定的原则和方法进行区分和归类,并建立起一定的分类系统和排列顺序,以便管理和使用。

【分类编码】是指对物品的类属进行管理的编码,其代码表示某一类相似或相同的物品。
【品种编码】是指对物品的种类进行管理的编码,其代码表示不同类别的物品。
【单品编码】是指对单一物品进行管理的编码,其代码表示每个不同的物品。

【属性编码】是指对物品相关属性信息进行管理的的编码。
【固有属性编码】是对物品本身的固有特性进行描述的编码,物品的固有特性在一段时间内是相对不变的,与物品的流动和交易等是不相关的。
【可变属性编码】是指随着物品在供应链中的流动和交易等变化而变化的物品属性编码。

【标示】是指将代码转换成为标志的过程。
【标志】是表明特征的记号,在物品标识中,标志的内容是将属性信息附着在载体上,形成记号。
”以事物或电子数据形式表现某一物品所具有的属性或特征的符号或标记“就是【标志】。

【载体】是指信息(包括知识)赖以存在的介质。
【识别】可以解释为对标志进行处理和分析,实现对物品进行描述,辨认,分类和解释的目的的过程。

【物联网编码体系】,包括应用层的编码,网络层的编码,感知层的编码,通过对物联网中的”物“进行唯一的标识,建立起”物“和唯一标识之间的一一对应关系。
【标识协议】,主要解决物联网资源编码在自动识别和感知载体中的承载,以建立资源统一的标识原则和方法,从而实现对信息可靠有效的识别和感知。
【解析体系】,根据物品编码如何获取信息服务,实现物物互联。

在物品编码标识【核心体系】中不仅包括编码和标识,还要考虑与网络系统,解析系统,应用系统的对接和数据交换。
国家物品编码标识的【支撑体系】主要由技术,管理,标准及法规四大部分组成。
【技术分体系】是物品编码标识系统的技术支撑。
【管理分体系】是物品编码标识系统建立和运转的指挥系统。
【标准分体系】是国家物品编码标识系统的运行基础和技术指南。
【法规分体系】是物品标识系统的法律和政策保障。

9月 152020
 
search = '168'
num_a = '1386-168-0006'
num_b = '1681-222-0006'

print(search + ' is at ' + str(num_a.find(search) + 1) + ' to ' + str(num_a.find(search) + len(search)) + ' of num_a ')
# 168 is at str(num_a.find(search) + 1) to str(num_a.find(search) + len(search)) of num_a
# 168 is at str(5 + 1) to str(5 + 3) of num_a
# 168 is at 6 to 8 of num_a
print(search + ' is at ' + str(num_b.find(search) + 1) + ' to ' + str(num_b.find(search) + len(search)) + ' of num_b ')
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python38/python.exe c:/Users/harveymei/hello.py
168 is at 6 to 8 of num_a 
168 is at 1 to 3 of num_b
PS C:\Users\harveymei>
9月 152020
 
#字符串的方法method
phone_number = '138-1234-5678'
hiding_number = phone_number.replace(phone_number[4:8], '*' * 4)
#第3-7个字符,不含第7个字符,即1234,替换为*,连续4个
print(hiding_number)
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python38/python.exe c:/Users/harveymei/hello.py
138-****-5678
PS C:\Users\harveymei>
9月 152020
 
#找到朋友中的魔鬼
word = 'friends'
find_the_evil_in_your_friends = word[0] + word[2:4] + word[-3:-1]
#f + ie + nd
print(find_the_evil_in_your_friends)
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python38/python.exe c:/Users/harveymei/hello.py
fiend
PS C:\Users\harveymei>
9月 152020
 
#字符串的分片与索引
name = 'My Name is Mike'

print(name[0])
'M'
#自左至右打印字符串第0个字符(从0开始)
print(name[-4])
'M'
#自右至左打印字符串第-4个字符(从-1开始)
print(name[11:14])
'Mik'
#冒号代表字符串分割从哪里开始到哪里结束
#自左至右打印字符串第11-14个字符,但不包含第14个字符
print(name[11:15])
'Mike'
#因此要打印Mike,自需要截取第11-15个字符,但不包含第15个字符
print(name[5:])
'me is Mike'
#自左至右从第5个字符到字符串的结束
print(name[: 5])
'My Na'
#自左至右截取第0-5个字符,但不包含第5个字符
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python38/python.exe c:/Users/harveymei/hello.py
M
M
Mik
Mike
me is Mike
My Na
PS C:\Users\harveymei>
9月 152020
 
#字符串赋值
word = 'a loooooong word'
#整数赋值
num = 12
#字符串赋值
string = 'bang!'
#字符串运算
total = string * (len(word) - num)
#total = 'bang!' * (len(word) - 12)
#total = 'bang!' * (16 - 12)
#len函数,计算字符串长度
print(total)
#连续四次
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python38/python.exe c:/Users/harveymei/hello.py
bang!bang!bang!bang!
PS C:\Users\harveymei> 
9月 152020
 
#变量数据类型,整数integer
num = 1
#变量数据类型,字符串string
string = '1'
#不同数据类型无法合并
print(num + string)
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python38/python.exe c:/Users/harveymei/hello.py
Traceback (most recent call last):
  File "c:/Users/harveymei/hello.py", line 6, in <module>
    print(num + string)
TypeError: unsupported operand type(s) for +: 'int' and 'str'
PS C:\Users\harveymei>

 

#变量数据类型,整数integer
num = 1
#变量数据类型,字符串string
string = '1'
#转换数据类型
num2 = int(string)

print(num + num2)
PS C:\Users\harveymei> & C:/Users/harveymei/AppData/Local/Programs/Python/Python38/python.exe c:/Users/harveymei/hello.py
2
PS C:\Users\harveymei>