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

安庆网站建设服务网b站推广费用一般多少

安庆网站建设服务网,b站推广费用一般多少,wordpress编辑器视频教程,网站建设费用的财务核算我们可以给列表中的所有数字分配一个唯一的值,重复时它会保留给它的值。这是一个非常常见的问题,在Web开发中,处理物品id时会遇到。让我们讨论一下解决这个问题的一些方法。 1. 使用enumerate() 列表解析 # initializing list test_list …

我们可以给列表中的所有数字分配一个唯一的值,重复时它会保留给它的值。这是一个非常常见的问题,在Web开发中,处理物品id时会遇到。让我们讨论一下解决这个问题的一些方法。

1. 使用enumerate() + 列表解析

# initializing list
test_list = [1, 4, 6, 1, 4, 5, 6]# printing the original list
print("The original list is : " + str(test_list))# using list comprehension + enumerate
# assign unique value to list elements
temp = {i: j for j, i in enumerate(set(test_list))}
res = [temp[i] for i in test_list]# printing result
print("The unique value list is : " + str(res))

输出

The original list is : [1, 4, 6, 1, 4, 5, 6]
The unique value list is : [0, 1, 3, 0, 1, 2, 3]

2. 使用setdefault() + map() + count()

from itertools import count# initializing list
test_list = [1, 4, 6, 1, 4, 5, 6]# printing the original list
print("The original list is : " + str(test_list))# using setdefault() + map() + count()
# assign unique value to list elements
res = list(map({}.setdefault, test_list, count()))# printing result
print("The unique value list is : " + str(res))

输出

The original list is : [1, 4, 6, 1, 4, 5, 6]
The unique value list is : [0, 1, 2, 0, 1, 5, 2]

3. 使用in,not in操作符和index

# initializing list
test_list = [1, 4, 6, 1, 4, 5, 6]# printing the original list
print ("The original list is : " + str(test_list))# assign unique value to list elements
x=[]
for i in test_list:if i not in x:x.append(i)
res=[]
for i in test_list:res.append(x.index(i))# printing result
print ("The unique value list is : " + str(res))

输出

The original list is : [1, 4, 6, 1, 4, 5, 6]
The unique value list is : [0, 1, 2, 0, 1, 3, 2]

4. 使用reduce()

from functools import reducetest_list = [1, 4, 6, 1, 4, 5, 6]
# printing the original list
print ("The original list is : " + str(test_list))unique_list = reduce(lambda l, x: l + [x] if x not in l else l, test_list, [])res = [unique_list.index(i) for i in test_list]
# printing result
print ("The unique value list is : " + str(res))

输出

The original list is : [1, 4, 6, 1, 4, 5, 6]
The unique value list is : [0, 1, 2, 0, 1, 3, 2]

5. 使用sorted()和bisect_left()

import bisect# initializing list
test_list = [1, 4, 6, 1, 4, 5, 6]# printing the original list
print ("The original list is : " + str(test_list))# assign unique value to list elements using sorted() and bisect_left()
sorted_list = sorted(test_list)
res = []
for i in test_list:idx = bisect.bisect_left(sorted_list, i)res.append(idx)# printing result
print ("The unique value list is : " + str(res))

输出

The original list is : [1, 4, 6, 1, 4, 5, 6]
The unique value list is : [0, 2, 5, 0, 2, 4, 5]

6. 使用numpy

import numpy as nptest_list = [1, 4, 6, 1, 4, 5, 6]
# printing the original list
print("The original list is:", test_list)# convert list to numpy array
arr = np.array(test_list)# get unique values and their indices
unique_arr, unique_indices = np.unique(arr, return_inverse=True)# get indices of unique values for each element in original list
res = unique_indices.tolist()# printing result
print("The unique value list is:", res)

输出

The original list is: [1, 4, 6, 1, 4, 5, 6]
The unique value list is: [0, 1, 3, 0, 1, 2, 3]
http://www.hkea.cn/news/101632/

相关文章:

  • 服务器托管是啥搜索引擎优化排名培训
  • 山西手机网站建设网址大全123
  • b2c平台有哪些平台网址新区seo整站优化公司
  • WordPress突然全站404网站如何添加友情链接
  • 复制别人网站做第一站seo短视频网页入口引流下载
  • 基层建设论文收录在哪个网站百度统计api
  • 购买主机可以做网站吗楚雄今日头条新闻
  • 深圳专业网站建设公司哪家好宁波网络营销公司
  • ps做电商网站流程图百度图片识别搜索引擎
  • 做电影网站程序好用武汉网站建设推广公司
  • 如何做b2c网站下列关于友情链接说法正确的是
  • 网站开发中网页上传seo在线网站推广
  • 网站建设报价流程免费培训网站
  • 聊城网站建设服务好最新网域查询入口
  • 一般网站建设流程有哪些步骤官方百度app下载安装
  • 档案网站建设的步骤八大营销方式有哪几种
  • 手机网站免费制作平台semseo
  • 周口市做网站小红书seo排名
  • 网站开始怎么做的ps培训
  • 去哪个网站找题目给孩子做保定百度首页优化
  • 五道口网站建设惠州seo外包服务
  • 如何查看网站是否备案企业宣传册
  • 好的网站建设公司排名互联网宣传推广
  • 上海买二手房做哪个网站好seo快速排名优化
  • 十大中国网站制作免费广告
  • wordpress 文章主题关键词推广seo
  • 佛山网站建设佛山网络推广代运营公司靠谱吗
  • 贵阳疫情最新消息站内seo优化
  • wordpress相关问题深圳百度关键字优化
  • 做国珍新时代 网站陕西seo顾问服务