如何从url加载yaml文件到python中的进程?

2024-04-25 22:22:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个yaml文件存储在URL位置。如何将其加载到python中进行处理? 这是我用来阅读的代码,然后简单地打印出来进行验证。但我没有看到yaml文件格式,在我看来像html。 代码:

import yaml
import urllib
from urllib import request

    x = urllib.request.urlopen("https://git.myplace.net/projects/groups%2users.yaml")
    User_Object = yaml.load(x)
    print(User_Object)
...

输出如下所示:

anch:create-branch-action":{"serverCondition":false}});}(_PageDataPlugin));</script><meta name="application-name" content="Bitbucket"><link rel="shortcut icon" type="image/x-icon" href="/s/-1051105741/5ab4b55/261/1.0/_/download/resources/com.atlassian.bitbucket.server.bitbucket-webpack-INTERNAL:favicon/favicon.ico" /><link rel="search" href="https://git.cnvrmedia.net/plugins/servlet/opensearch-descriptor" type="application/opensearchdescription+xml" title="Bitbucket code search"/></head><body class="aui-page-sidebar bitbucket-theme"><ul id="assistive-skip-links" class="assistive"><li><a href="#aui-sidebar-content">Skip to sidebar navigation</a></li><li><a href="#aui-page-panel-content-body">Skip to content</a></li></ul><div id="page"><!-- start

文件名为“groups+users.yaml”。python解析/处理yaml格式的最佳读取方式是什么


Tags: 代码httpsimportgityamlbitbucketnetrequest