我一直致力于将Python代码转换成与我的研究工作相关的Java,我在Python中有一个查询。
伦恩
()对象。我的问题出现在提供的代码中的[::-1]。
我曾尝试在Java中通过简单的增量循环来实现它,但它不起作用。它在temp_line.split(“$target/”)[1]处给出数组超出绑定的异常。
for i in range(0, script_lines.__len__())[::-1]:
temp_line = script_lines[i]
if "$target/" in temp_line and "cp" in temp_line:
Case_num = 1 + int(temp_line.split('$target/')[1].split('.txt')[0])
return Case_num
我想知道代码中的[::-1 ]是什么意思,这样我就可以把它转换成Java。