我是靠谱客的博主 自信龙猫,最近开发中收集的这篇文章主要介绍python list函数替换逗号为竖杠,Python数组切片用逗号?,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

I was wondering what the use of the comma was when slicing Python arrays - I have an example that appears to work, but the line that looks weird to me is

p = 20*numpy.log10(numpy.abs(numpy.fft.rfft(data[:2048, 0])))

Now, I know that when slicing an array, the first number is start, the next is end, and the last is step, but what does the comma after the end number designate? Thanks.

解决方案

It is being used to extract a specific column from a 2D array. Refer to the first examples here.

So your example would extract column 0 (the first column) from the first 2048 rows (0 to 2047). Note however that this syntax will only work for numpy arrays and not general python lists.

最后

以上就是自信龙猫为你收集整理的python list函数替换逗号为竖杠,Python数组切片用逗号?的全部内容,希望文章能够帮你解决python list函数替换逗号为竖杠,Python数组切片用逗号?所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(29)

评论列表共有 0 条评论

立即
投稿
返回
顶部