
我正在学习使用 GitHub,我发现我的默认分支main虽然我已将其更改为master使用我在 GitHub 网站中的帐户,但它仍然在命令行上显示为main. 它在每个git push命令的身份验证过程中引起了很多问题,我想像往常一样将主分支更改为 (master => origin) 。谁能帮我?
如果我有这样的模块文件夹结构:
studio
tools
__init__.py
camera
__init__.py
camera.py
element
__init__.py
element.py
Run Code Online (Sandbox Code Playgroud)
如何编写 __init__.py 文件来制作它,以便我可以编写如下所示的导入语句?模块中有一个camera名为CameraNode我想调用的类对象,如下面的示例所示。
studio
tools
__init__.py
camera
__init__.py
camera.py
element
__init__.py
element.py
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 (Python) 下载在浏览器中呈现的 PDF 文件(未显示为弹出窗口或下载)playwright。没有公开 URL,因此您不能简单地抓取链接并使用requests.get("file_url").
我试过了:
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch(headless=False)
page = await browser.newPage(acceptDownloads=True)
await page.goto("www.some_landing_page.com")
async with page.expect_download() as download_info:
await page.click("a") # selector to a pdf file
download = download_info.value
path = download.path()
Run Code Online (Sandbox Code Playgroud)
我也尝试过page.expect_popup(),但没有运气。我的理解是,这不能使用 来完成pyppeteer,但如果可能的话,也欢迎这种方式的解决方案。
我是我们之间 Discord 公会的所有者,我在其中实施了一些机器人。当我们播放语音通话时,有时人们会忘记将自己静音,以便我们可以听到它们,这通常会揭示有价值的信息。
我正在尝试设计一组命令,让一个人可以轻松地将语音通道中的每个人静音。他们使用该命令claim "VC Name"在指定的语音通道上声明命令,然后使用该命令set_mute "true/false"将所有人静音或取消静音。我已经关闭了第一部分,但我正在努力处理实际上使语音通道成员静音/取消静音的第二部分的代码。
在阅读 discord.py 的文档时,我发现了一些可能有用的选项,但我不知道如何执行它们中的任何一个。
discord.VoiceState(文档):discord.VoiceState具有属性mute,muted和self_mute。也许可以使用诸如member.VoiceState.mute = True,member.VoiceState.muted = True或 之类的东西来修改成员的语音状态member.VoiceState.self_mute = True。我不确定如何使用此方法,因为使用上述代码行会生成AttributeError.discord.Member.edit(文档):member.Member.edit可以选择设置mute为 True。这实际上将成员设置为服务器静音(我似乎无法撤消它),所以我宁愿避免使用此选项,除非通过此方法有解决方案。这是我现在拥有的代码。在最后一条if/else语句下,我将把解决方案用于将通话中的成员静音和取消静音。
async def mute(ctx, setting):
regex, claimed = re.compile(f"_VC: (Lobby [0-9])_"), False
for role in cx.message.author.roles:
if regex.search(role.name):
claimed = True
break
if not claimed:
await ctx.send("You …Run Code Online (Sandbox Code Playgroud) 我想对多索引数据帧的数据进行排序,同时保持更高级别的索引相同。
这是数据样本:
data = {
'Column 1': [1., 2., 3., 4.,34,2,5,6],
'Index1 Title': [
"Apples", "Apples", "Puppies", "Puppies",
'Oranges','Oranges','Blue berries','Blue berries'],
'index2 Title': [
'Inside', 'Outside', 'Inside', 'Outside',
'Inside', 'Outside', 'Inside', 'Outside'
]
}
df = pd.DataFrame(data)
df.set_index(['Index1 Title','index2 Title'],inplace=True)
Run Code Online (Sandbox Code Playgroud)
我得到这个输出:
Index1 Title index2 Title Column 1
Apples Inside 1.0
Outside 2.0
Puppies Inside 3.0
Outside 4.0
Oranges Inside 34.0
Outside 2.0
Blue berries Inside 5.0
Outside 6.0
Run Code Online (Sandbox Code Playgroud)
当我尝试这段代码时:
df.sort_values('Column 1', ascending=False)
我明白了:
Index1 Title index2 Title Column 1
Oranges …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 git-python 添加、提交并推送到存储库。根据不完整的文档和此处的示例,我尝试了以下方式:
myrepo = Repo('Repos/hello-world/.git')
# make changes to README.md
myrepo.index.add('README.md')
myrepo.index.commit("Updating copyright year")
myrepo.git.push("origin", "copyright_updater") ###
Run Code Online (Sandbox Code Playgroud)
我检查了存储库hello_world并将其放在一个文件夹下Repos。我确实更改了一个文件,即README.md. 但是使用该代码我得到一个错误
git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
cmdline: git push origin copyright_updater
stderr: 'error: src refspec copyright_updater does not match any.
error: failed to push some refs to 'git@github.com:alex4200/hello-world.git''
Run Code Online (Sandbox Code Playgroud)
在标记线上。
我该如何修复它,以便将更改推送到新分支并在 GitHub 上创建拉取请求?
我的计算机上的 Git Bash 遇到了一些问题。我一直在尝试打包和分发存储库,但是某些命令无法在 Git Bash 上正常运行。但是,它们确实可以在其他命令行界面上工作,因此我感觉这是我计算机上安装的 Git Bash 的问题。
毫不奇怪,我的计算机上有很多 Git 存储库。我的理想计划是卸载并重新安装 Git,并假设本地存储库仍然存在,从我上次停下的地方继续。如果不满足假设,则大多数本地存储库与远程存储库都是最新的,因此在本地初始化存储库并将每个存储库的当前提交拉到每个本地存储库不会太困难。但是,考虑到我拥有的存储库数量,这会有点耗时。
我尝试在互联网和 Stack Overflow 上进行搜索,但我没有找到任何关于卸载 Git 是否会删除我的远程存储库或使它们变得无用的答案(或问题)。我有一种预感,这种情况不会发生,但我想确定情况确实如此。
python ×4
git ×3
discord.py ×1
git-bash ×1
github ×1
gitpython ×1
multi-index ×1
pandas ×1
playwright ×1
pyppeteer ×1
python-3.x ×1