我已经用一个预定义的变量编写了一个运行的python代码。
variable = "first_variable"
#code
with open(f"{variable}.txt", "w") as w_file:
w_file.write("Something")
我现在想
适应
该代码接受任意数量的变量作为参数,并逐个处理它们。
在shell中,我想这样称呼它:
python3 code.py first_variable second_variable third_variable n_variable
你知道我该怎么做吗?我尝试使用输入、创建函数或使用while循环,但失败了。。。