python变量后面加中括号_括号和范围中的python变量

本文探讨了Python代码中变量后面跟随中括号的含义,以`[i]+[0]*n`为例,解释了这种语法结构的作用。在计算Levenshtein距离的算法示例中,该表达式用于构建数组。同时,文章提到了代码中遇到的`tabError`,指出缩进问题在Python中的重要性。
摘要由CSDN通过智能技术生成

这是什么意思([i]+[0]*n)为什么是

0

在括号里?是吗?

previous, current = current, [i]+[0]*n

为什么我不能在下一行打印当前值?就像这样:

previous, current = current, [i]+[0]*n

print(current)

我有一个错误:

tabError:缩进中制表符和空格的使用不一致

#!/usr/bin/env python

# This is a straightforward implementation of a well-known algorithm, and thus

# probably shouldn't be covered by copyright to begin with. But in case it is,

# the author (Magnus Lie Hetland) has, to the extent possible under law,

# dedicated all copyright and related and neighboring rights to this software

# to the public domain worldwide, by distributing it under the CC0 license,

# version 1.0. This software is distributed without any warranty. For more

# information, see

def levenshtein(a,b):

"Calculates the Levenshtein distance between a a

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值