社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  blueteeth  »  全部回复
回复总数  4

choice[1] 正在做 1[1] 这没道理。我想你想要 li[choice][1] . 即

if li[choice][1] == "t":
6 年前
回复了 blueteeth 创建的主题 » 列表中的Python运算符星号[重复]

当你这样做的时候,你只是创建列表的副本,n次。

所以这里的内部列表实际上是相同的列表。当你修改第一个时,你也在修改第二个。如果不需要该功能,可以执行以下操作:

a = [[1 for _ in range(2)] for _ in range(2)]

index() 需要接受你正在寻找的价值( x )以及最初为0的当前索引。

我的假设是:

  • value 是链接列表的标题。
  • tail
  • 如果没有下学期, 没有。
class LinkedList:
    def __init__(self, value, tail):
        self.value = value
        self.tail = tail

    def index(self, x, i=0):
        if self.value == x:
             return i
        if self.tail is None:
             raise IndexError
        return self.tail.index(x, i+1)
7 年前
回复了 blueteeth 创建的主题 » 在python中,如何在数据帧索引列表上循环300个数据点?

看来你可以在 flux_maxij . 所以你大概也可以访问切片?

您可以使用

flux_maxij[0:300]
# OR
start = 0
flux_maxij[start:start+300]

以及 init_list 似乎包含[0,300,600,…]

init_list = list(range(0, len(flux_maxij), 300))  # range from 0 to the total length, jumping 300 each time
median_list = []
for i in init_list:
    holding = sorted(flux_maxij[i:i+300])  # get the next bit of the list and sort it
    median_list.append(holding[149])  # append the median

x = np.array([init_list])
y = np.array([median_list])

plt.plot(x, y, 's')

这样行吗?不知道是什么很难理解 是。