小编PCH*_*CHC的帖子

如何使用Microsoft Graph API获取当前站点的siteId?

从文档中,我找不到任何方法来获取我放置webpart的网站的siteId.

例如,

我当前的网站是:https://{hostname}/sites/main1< - 不是root网站,但我想获得这个siteId

我在这里测试我的webpart: https://{hostname}/sites/main1/_layouts/15/workbench.aspx

我怎样才能做到这一点?从文档中,

站点是唯一标识符,它是以下值的组合ID:

网站集主机名(contoso.sharepoint.com)

网站集唯一ID(guid)

网站唯一ID(guid)

我可以通过使用location.hostname(是的,我使用JavaScript + React构建我的webpart)轻松获取主机名,但是如何使用Graph API轻松获取site-id?

sharepoint-online microsoft-graph spfx

6
推荐指数
1
解决办法
9413
查看次数

具有2个迭代器和2个范围的for循环

我是Python的新手,并且正在处理prime生成器。我要使用的算法是Atkin的Sieve

目前,我正在尝试按照算法的伪代码进行练习。但是,我遇到了一个问题,因此找不到任何参考。(也许我不擅长搜索...)。在伪代码中,for (x, y) in [1, ?limit] × [1, ?limit]:...让我感到困惑。我知道这是什么意思,但不知道如何将此代码转换为Python代码。

抱歉,如果我的问题不合适,谢谢您的帮助。:)

以下是我的代码的一部分。

itx = iter(range(1, int(limit**0.5)))
ity = iter(range(1, int(limit**0.5)))
for x, y in zip(itx, ity):
    n = 4*(x**2)+(y**2)
    if n <= limit and (n%12 == 1 or n%12 == 5):
        sieve[n] = not sieve[n]

    n = 3*(x**2)+(y**2)
    if n <= limit and n%12 == 7:
        sieve[n] = not sieve[n]

    n = 3*(x**2)-(y**2)
    if x > y and n <= limit and n%12 == 11:
        sieve[n] …
Run Code Online (Sandbox Code Playgroud)

python iterator loops

2
推荐指数
1
解决办法
1033
查看次数