Reputation: 586
I have taken a command line input as
dataset = sys.argv[1]
Where suppose I have a stem data set named as : IRIS
Now there are 3 extensions of this IRIS dataset, i.e IRIS.names, IRIS.data, IRIS.test
Suppose in my code at a particular point I need to use the dataset IRIS.names
How can I do it?
I have tried like :
with open(dataset".names") as f:
with open("dataset.names") as f:
These above two are giving me errors.
If I write with open("IRIS.names") as f:
then this will work fine. But I am not supposed to write the file name directly inside my program, instead I need to take the stem file name (i.e IRIS) as command line argument.
Upvotes: 0
Views: 59
Reputation: 54698
This is just string concatenation.
with open(dataset+".names") as f:
Upvotes: 1