python as regard to list

列表

定义

[]内以逗号分隔,按照索引,存放各种数据类型,每个位置代表一个元素

特点

1.可以存放多个值
2.按照从左到由的顺序定义列表元素,下表从0有序访问

listhuangliuwang
索引 0123

3.可以修改索引对应位置的值

操作

先定义一个列表

a = ['huang', 'liu', 'wang']
追加
a.append('xu')    #在 列表 a 后追加

插入:选择索引位置插入,原先位置各往后移一位

a.insert(2, 'bo')

合并

name1 = ['huang', 'liu', 'wang']
name2 = ['lei', 'bo']
name1.extend(name2)
print(name1)

output : [‘huang’, ‘liu’, ‘wang’, ‘lei’, ‘bo’]

表示在name1后面追加name2赋值给name1

列表嵌套

name1.insert(2, name2)
print(name1)
print(name1[2][1])

output :
[‘huang’, ‘liu’, [‘lei’, ‘bo’], ‘wang’, ‘lei’, ‘bo’]
bo

删除

del 删除
删除列表指定索引元素,或者直接删除列表

del name1[2]

pop删除

deletter = name1.pop()

将name1中最后一个元素删除,同时可将被删除元素赋值给deletter,同时也可以指定索引删除

清空

name1.clear()

判断,查找

if 'huang' in name1:                  #  判断'huang'是否在列表中
    a = name1.index('huang')          # 查找'huang'的索引
    b = name1.count('huang')          # 统计'huang'的个数

切片

name1[3:6]
name1[: 6]        # 从0开始
name1[3:]         # 到最后结束
name1[-3: -1]     # 倒切
name1[0: -1:3]    # 从头到尾,步长为2,不写的话默认为1

列表排序

name1.sort()          # 对列表name1元素重新排序,返回到name1中
name1.reverse()       # 对列表元素反转

循环列表

for i in enumerate(name1)
    print(i)

将列表以列表形式把索引与对应元素打印出来
(0, ‘wang’)
(1, ‘liu’)
(2, ‘lei’)
(3, ‘huang’)
(4, ‘bo’)

直接打印出索引对应元素

for i in enumerate(name1):
  print(i[0], i[1])

0 wang
1 liu
2 lei
3 huang
4 bo

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
翻译Agent 𝑐 𝑖 . In this paper, we regard each charging station 𝑐 𝑖 ∈ 𝐶 as an individual agent. Each agent will make timely recommendation decisions for a sequence of charging requests 𝑄 that keep coming throughout a day with multiple long-term optimization goals. Observation 𝑜 𝑖 𝑡 . Given a charging request 𝑞𝑡 , we define the observation 𝑜 𝑖 𝑡 of agent 𝑐 𝑖 as a combination of the index of 𝑐 𝑖 , the real-world time 𝑇𝑡 , the number of current avail able charging spots of 𝑐 𝑖 (supply), the number of charging requests around 𝑐 𝑖 in the near future (future demand), the charging power of 𝑐 𝑖 , the estimated time of arrival (ETA) from location 𝑙𝑡 to 𝑐 𝑖 , and the CP of 𝑐 𝑖 at the next ETA. We further define 𝑠𝑡 = {𝑜 1 𝑡 , 𝑜2 𝑡 , . . . , 𝑜𝑁 𝑡 } as the state of all agents at step 𝑡. Action 𝑎 𝑖 𝑡 . Given an observation 𝑜 𝑖 𝑡 , an intuitional design for the action of agent𝑐 𝑖 is a binary decision, i.e., recommending 𝑞𝑡 to itself for charging or not. However, because one 𝑞𝑡 can only choose one station for charging, multiple agents’ actions may be tied together and are difficult to coordinate. Inspired by the bidding mechanism, we design each agent 𝑐 𝑖 offers a scalar value to "bid" for 𝑞𝑡 as its action 𝑎 𝑖 𝑡 . By defining 𝑢𝑡 = {𝑎 1 𝑡 , 𝑎2 𝑡 , . . . , 𝑎𝑁 𝑡 } as the joint action, 𝑞𝑡 will be recommended to the agent with the highest "bid" value, i.e., 𝑟𝑐𝑡 = 𝑐 𝑖 , where 𝑖 = arg max(𝑢𝑡)
07-11

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值