当我尝试使用以下命令进行提交时,我在提交时遇到问题,例如:
$ git commit -m "add readme"
pre-commit not found. Install pre-commit with the command pip3 install --user pre-commit or follow the steps on official documentation: https://pre-commit.com /#install
Run Code Online (Sandbox Code Playgroud)
按照我通过命令安装的预提交安装文档中描述的步骤:
$ pip install pre-commit
Run Code Online (Sandbox Code Playgroud)
但是,当我触发命令时,会发生以下错误:
$ pre-commit --version
bash: pre-commit: command not found
Run Code Online (Sandbox Code Playgroud)
我的尝试失败了,所以我尝试了一些其他解决方案,但它们不起作用。
我已经尝试过所描述的解决方案,即使用~./bashrc命令导出我的:source ~/.profile但出现以下错误:
bash:/Users/pvieira/.profile: No such file or directory
Run Code Online (Sandbox Code Playgroud)
这会导致与上述手动安装时发生的错误相同的错误pip。

Warning: `dart` on your path resolves to /usr/lib/dart/bin/dart, which is
not inside your current Flutter SDK checkout at /home/ankit/flutter.
Consider adding /home/ankit/flutter/bin to the front of your path.
Run Code Online (Sandbox Code Playgroud)
这个异常是在flutter更新时开始的。我该如何解决这个问题?
我有下一个提交:
* be23d923d (HEAD -> bot) Dump more info
* 506b1b5a7 (office/bot) Fix IP for registry.gitlab.office
* fb7e89677 Show build log on failure
* 58c2e3606 Merge branch 'implement_test' into test2
Run Code Online (Sandbox Code Playgroud)
运行后git pull -v --rebase=merges,结果为:
* 42852fd6b (HEAD -> bot) Dump more info
* a3c657c09 (office/bot) Echo $IMAGE_TAG
* 506b1b5a7 Fix IP for registry.gitlab.office
* fb7e89677 Show build log on failure
* 58c2e3606 Merge branch 'implement_test' into test2
Run Code Online (Sandbox Code Playgroud)
这是该命令的日志:
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), …Run Code Online (Sandbox Code Playgroud) 我正在尝试将category_id 用作纯数值,这有效。我还需要捕获category_name。对于category_name,我需要捕获直到空格或包含空格(如果它以双引号开头)。
用户输入字符串示例:
python c:192 c:1Stackoverflow c:"Stack Overflow2"
Run Code Online (Sandbox Code Playgroud)
所需的捕获应该是category_name 的这两个值和category_id 的192 值。
预期输出:
1Stackoverflow
Stack Overflow2
Run Code Online (Sandbox Code Playgroud)
Category_name 必须至少包含一位非数字,但可以是全字母且不含数字。
此查询部分有效:
python c:192 c:1Stackoverflow c:"Stack Overflow2"
Run Code Online (Sandbox Code Playgroud)
它不捕获输入1Stackoverflow,但捕获引用的输入。我需要删除引号:
1Stackoverflow
Stack Overflow2
Run Code Online (Sandbox Code Playgroud)
这?!\d+是一种避免与category_id发生冲突的尝试,但似乎不起作用。
如何以两种形式(一个单词和引号分隔)捕获category_name,而不在捕获中使用引号并使用前导数字?
我有一个工作代码块,但似乎应该有一个更有效的算法,大概需要更少的循环或使用库/模块。
此示例版本的代码采用一个字符串列表,按 反向排序len(),然后构建一个新列表:
gs = ["catan", "ticket to ride", "azul"]
mg = {}
for i in range(len(gs)):
mg[i] = len(gs[i])
popularity = {k: v for k, v in sorted(mg.items(), key=lambda v: v[1], reverse=True)}
tg = []
for game in popularity.keys():
tg.append(gs[game])
Run Code Online (Sandbox Code Playgroud)
生产代码未设置mg[i]为len(),并且列表中的元素不一定是字符串,但算法以其他方式工作。
为此,相同的输出是:
['ticket to ride', 'catan', 'azul']
Run Code Online (Sandbox Code Playgroud)
如何提高这个算法的效率?
git ×2
algorithm ×1
bash ×1
dart ×1
flutter ×1
git-commit ×1
javascript ×1
pre-commit ×1
python ×1
regex ×1
sorting ×1
ubuntu ×1