我正在寻找有关在 Python 中解析文件的更多信息,特别是来自某人的 GitHub。例如,如果人 A 有一个 GitHub 帐户,其中包含一个包含以下内容的文件:
name = Person A
my script = scriptA.sh
script output = yarn output
my other files = fileA, fileB
我希望能够访问这些信息并使用我的 Python 脚本进行存储。
这不适用于课程或任何东西,因此我正在努力寻找关于此类概念的良好、清晰、初学者级别的信息。有人在这里有什么建议吗?我有基本的解析和 Python 理解,但我想推进这一点。这是我用来尝试集思广益的一些伪代码。
def parseAddFile(filename):
with open(filename, 'r') as file:
lines = file.readlines() # this should read all the lines of the file
dict_of_contents={} # this will then put the contents into a dictionary
for parameter in line
name =
ETC...
只是想增加我的知识,而不是仅仅寻求答案。