小编yip*_*iez的帖子

如何根据扩展名打开文件?

我想在同一目录中打开任何 .txt文件.

在红宝石中我能做到

File.open("*.txt").each do |line|
       puts line
end
Run Code Online (Sandbox Code Playgroud)

在python我不能这样做它会给出一个错误

file = open("*.txt","r")
print(file.read())
file.close()
Run Code Online (Sandbox Code Playgroud)

它给出了一个错误无效的参数.

那有什么办法吗?

python file

0
推荐指数
1
解决办法
46
查看次数

标签 统计

file ×1

python ×1