打开一个名称包含在变量中的文件

KKc*_*KKc 0 python file

我在一个文件夹中有一百个文件,其中的形式i.ext是我是一个整数(0 <= i).我写了一个脚本,在条目中包含2个文件,但我想将脚本与我文件夹的所有文件一起使用.

我可以用Python编写一个Python脚本,使得名称文件在这样的变量中:

from difference import *
# I have a module called "difference"
for i in range (0,100):
 for j in range (0,100):
   leven(i+".ext",j+".ext")          #script in module which take two files in entries
Run Code Online (Sandbox Code Playgroud)

显然我的代码是错的,但我不知道我该怎么做:(

Ign*_*ams 5

您无法在Python中添加数字和字符串.

'%d.ext' % (i,)
Run Code Online (Sandbox Code Playgroud)