擅长:python、mysql、java
<p><strong>Lua:</strong></p>
<pre><code>> = string.sub("Hello Lua user", 7) from character 7 until the end
Lua user
> = string.sub("Hello Lua user", 7, 9) from character 7 until and including 9
Lua
> = string.sub("Hello Lua user", -8) 8 from the end until the end
Lua user
> = string.sub("Hello Lua user", -8, 9) 8 from the end until 9 from the start
Lua
> = string.sub("Hello Lua user", -8, -6) 8 from the end until 6 from the end
Lua
</code></pre>
<p><strong>Python:</strong></p>
^{pr2}$
<p>Python与Lua不同,是零索引,因此字符计数不同。数组开始于<a href="https://stackoverflow.com/questions/2785704/why-do-lua-arraystables-start-at-1-instead-of-0">from 1 in Lua</a>,在Python中为0。在</p>
<p>在Python切片中,第一个值为inclusive,第二个值为exclusive(直到但不包括)。空的第一个值等于零,空的第二个值等于字符串的大小。在</p>