小编Zor*_*gan的帖子

获取两个字符串之间的字符

<p>I'd like to find the string between the two paragraph tags.</p><br><p>And also this string</p>
Run Code Online (Sandbox Code Playgroud)

我如何获得前两个段落标记之间的字符串?然后,我如何获得第2段标签之间的字符串?

python django

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

在我的Django TextField中点击链接

我有一个像这样的Textfield:

class Comment(models.Model):
    ...
    comment_text = models.TextField(max_length=650, blank=True, null=True)
Run Code Online (Sandbox Code Playgroud)

当有人张贴的链接TextField,例如www.stackoverflow.com,我希望它是可点击(嵌套在一个<a>标签).有没有办法用代码而不使用文本编辑器?

html javascript python django jquery

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

如何使用内联css对文本执行双删除?

我希望我的文本有2个删除线,但使用内联CSS.

我怎样才能做到这一点?

html css

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

sortedBy() 选择器未对列表进行排序

我有一个sortedBy{}声明打算List按元素的长度对a 进行排序String

var animals: List<String> = listOf("tiger", "cat", "dragon", "elephant")
fun strLength(it: String) = it.length
animals.sortedBy { strLength(it) }
animals.forEach {println(it)}
Run Code Online (Sandbox Code Playgroud)

但是它只打印初始订单。知道为什么吗?

kotlin

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

为什么Lateinit在对象类型上起作用而在原始类型上不起作用?

这个答案说对象类型在对象类型的lateinit上使用null值。有人可以详细说明吗?“使用空值”是什么意思?

此外,它说“对于原始类型,没有这样的值”-为什么没有

kotlin

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

如何动态从 Firestore 数组中删除多个元素?

我想从 Firestore 数组中删除多个元素:

var eliminatedThisRound = []

for (const player in players){
    if (players[player].eliminated === false && players[player].answer !== answer) {
        eliminatedThisRound.push(players[player].uid);
    }
}
var update = {
    roundFinished: true,
    nextRound: date.valueOf() + 12000,seconds
    players: updatedPlayers,
    remainingPlayers: admin.firestore.FieldValue.arrayRemove(eliminatedThisRound)
}
await t.update(gameRef, update);
Run Code Online (Sandbox Code Playgroud)

上面返回此错误:

transaction failure: Error: Element at index 0 is not a valid array element. Nested arrays are not supported. 
Run Code Online (Sandbox Code Playgroud)

所以如果我知道这些值就好了,因为我可以做这样的事情:

remainingPlayers: admin.firestore.FieldValue.arrayRemove("player1", "player2")
Run Code Online (Sandbox Code Playgroud)

但是我还没有找到使参数动态化的方法arrayRemove()

任何想法?

node.js firebase google-cloud-platform google-cloud-functions google-cloud-firestore

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

自定义字体未显示在 SwiftUI 中

我已按照 Apple 教程中的所有步骤添加自定义字体

我已将字体文件添加到名为的文件夹下fonts

在此输入图像描述

我已通过将字体添加到以下位置来注册字体Info.plist

在此输入图像描述

然而 Xcode 无法使用它们/找到它们:

Button(action: {}){
                Text("View profile")
                    .font(Font.custom("seravekBold.tff", size: 20.0))
Run Code Online (Sandbox Code Playgroud)

我也尝试过测试这个方法:

for family in UIFont.familyNames.sorted() {
    let names = UIFont.fontNames(forFamilyName: family)
    print("Family: \(family) Font names: \(names)")
}
Run Code Online (Sandbox Code Playgroud)

在 my 中AppDelegate打印所有 UI 字体,但我添加的字体 ( seravek) 不显示。

知道问题是什么吗?

xcode ios swift swiftui

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

如何在 SwiftUI 中为链接加下划线?

这是我的链接:

Link("Terms + Conditions", destination: URL(string: "https://my.app/terms_and_conditions.html")!)
Run Code Online (Sandbox Code Playgroud)

我知道它Text()有一个underline()修饰符,但似乎没有一个用于Link().

任何的想法?

ios swift swiftui

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

如何调用 Google Cloud Functions 中的 Express 函数?

这是我的快速端点,它是通过Stripe 的 webhook调用的:

\n
const functions = require(\'firebase-functions\');\nconst bodyParser = require(\'body-parser\')\nconst app = require(\'express\')();\nconst stripe = require(\'stripe\')(functions.config().stripe.test.secret);\nconst endpointSecret = functions.config().stripe.test.webhookkey;\n\napp.post(\'/stripe_webhook\', bodyParser.raw({type: \'application/json\'}), async (request, response) => {\n    const event = request.body;\n    // Only verify the event if you have an endpoint secret defined.\n    // Otherwise use the basic event deserialized with JSON.parse\n    if (endpointSecret) {\n    // Get the signature sent by Stripe\n    const signature = request.headers[\'stripe-signature\'];\n    try {\n      const eventConstruct = stripe.webhooks.constructEvent(\n        request.body,\n        signature,\n        endpointSecret\n      );\n    } catch (err) …
Run Code Online (Sandbox Code Playgroud)

node.js express stripe-payments firebase google-cloud-functions

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

如何在 C# 中存储有组织的常量列表

我想存储每个游戏级别的固定设置。我希望它的结构如下:

namespace LevelSettings
{
    namespace Bar
    {
        public static int ExtraActiveBlocks = 3;

        "Level1"
        {   public static float Speed = 0.6f;
            public static string ActiveColor = "red";
            public static string InactiveColor = "black";
        },
        "Level2"
        {
            public static float Speed = 0.6f;
            public static string ActiveColor = "red";
            public static string InactiveColor = "black";
        },
        "Level3"
        {
            public static float Speed = 0.6f;
            public static string ActiveColor = "red";
            public static string InactiveColor = "black";
        }
Run Code Online (Sandbox Code Playgroud)

这显然不是有效的 C# 代码。不过我想问如何用 C# …

c# unity-game-engine

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