使用参数读取文件

时间:2019-05-03 12:20:52

标签: python-3.x

我有一个用例来读取带有参数的文本文件。参数应替换为我们在运行脚本时作为输入提供的命令行参数。

示例:

This is python which is #param1 language.
Python is #param2 in machine learning.

#param1: good
#param2: rich

Output:
This is python which is good language.
Python is rich in machine learning.

我可以在“读取”模式下打开文件,但是如何以编程方式替换自变量? 在此先感谢!

0 个答案:

没有答案