小编San*_*nth的帖子

为什么即使路径不存在,Path(...).exists 也为 true?

我应该要求用户输入一个目录,如果该目录不存在,我们告诉他们,然后为他们创建一个目录。

这是我到目前为止的代码。无论输入的路径的目录是否实际存在,它都会以相同的方式进行操作。在 Windows 上使用 pathlib 时会发生这种情况。错误报告 Issue35692

import pathlib
from pathlib import Path

def directory():

    p = Path(input("Enter file path: "))

    if p.exists:

        print('Exists')

        return p

    else:

        print('Directory does not exist. Making directory for you.')

        p.mkdir()



directory()
Run Code Online (Sandbox Code Playgroud)

python windows directory pathlib

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

如何以及在哪里访问 gatsby 中的 html 正文

我遇到了网页右侧和底部出现大空白的问题。测试网页的响应能力时。

我在stackoverflow上发现了类似的问题

  1. 当背景图像应延伸页面的整个长度时,页面右侧会出现空白[关闭]

  2. 当浏览器调整为较小的窗口时,网站页面右侧出现奇怪的空白

两个帖子的解决方案都是一样的

html, 
body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden; 
}
Run Code Online (Sandbox Code Playgroud)

我不知道在哪里添加这个gatsby,我发现了一个与我的问题类似的帖子,关于gatsby 如何设计主体/背景的样式?。似乎不明白这个问题的解决方案是什么!

找到这篇文章How to add adynamic class to body tag in Gatsby.js? 对使用有一些想法react-helmet,我到底可以如何使用它?

谁能解释我如何html body在盖茨比中设置,以避免这个大的空白?

Resolution 1366x768边框下方的区域是空白区域 分辨率 1366x768

Resolution 1920x1080边框下方的区域是空白区域 在此输入图像描述

html javascript css gatsby react-helmet

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

vitePluginString 不是函数

创建了一个 vite + svelte

\n
$ npm init vite@latest\n\xe2\x9c\x94 Project name: \xe2\x80\xa6 app1\n\xe2\x9c\x94 Select a framework: \xe2\x80\xba svelte\n\xe2\x9c\x94 Select a variant: \xe2\x80\xba svelte-ts\n
Run Code Online (Sandbox Code Playgroud)\n

想要包含vite-plugin-string来使用glsl文件

\n

已安装

\n

npm install --save-dev vite-plugin-string

\n

配置vite.config.js文件如下

\n
$ npm init vite@latest\n\xe2\x9c\x94 Project name: \xe2\x80\xa6 app1\n\xe2\x9c\x94 Select a framework: \xe2\x80\xba svelte\n\xe2\x9c\x94 Select a variant: \xe2\x80\xba svelte-ts\n
Run Code Online (Sandbox Code Playgroud)\n

只要跑起来npm run dev

\n

我收到这个错误

\n
> app1@0.0.0 dev\n> vite\n\nfailed to load config from ....../Six/trailRun/vite.config.js\nerror when starting dev server:\nTypeError: …
Run Code Online (Sandbox Code Playgroud)

svelte vite

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

动态检测屏幕高度和屏幕宽度,以精简图像的高度和宽度

我只能使用下面的代码来标记display,正如corrl这篇文章的回复中提到的divportrait

<script context="module">
    import Viewport from 'svelte-viewport-info'
</script>

<div class="only-portrait">
    only visible in Portrait Mode
</div>

<style>
    :global(.Landscape .only-portrait) {
        display: none;
    }
    :global(.Portrait .only-portrait) {
        display: block;
        background: black;
        color: white;
        padding: 2rem;
    }
</style>
Run Code Online (Sandbox Code Playgroud)

按预期工作

portrait但是,当视口的尺寸更具体时,图像元素尺寸之一(高度和宽度)需要在模式中减小height.viewport <= 133% of width.viewport

在此输入图像描述

我尝试从内部和外部窗口绑定获取viewport height并使用代码width

<script>
    $: outerWidth = 0
    $: outerHeight = 0
</script>

<svelte:window bind:innerWidth bind:outerWidth bind:innerHeight bind:outerHeight />
Run Code Online (Sandbox Code Playgroud)

尝试使用jquery根据条件改变图像的宽度和高度viewport.width*1.33 <= viewport.height

如这里 …

css jquery svelte

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

Composer-php安装错误

我有一个内容为composer.json的内容:

{
  "require":{
    "paypal/rest-api-sdk-php": "*"
  }
}
Run Code Online (Sandbox Code Playgroud)

在尝试通过以下命令安装作曲家时composer install

我收到此错误消息:

您的要求无法解决为一组可安装的软件包。

完整的错误日志:

Problem 1
- paypal/rest-api-sdk-php v1.7.1 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- paypal/rest-api-sdk-php v1.7.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- paypal/rest-api-sdk-php v1.6.4 requires ext-curl * -> the requested PHP extension curl is missing from your system.
- paypal/rest-api-sdk-php v1.6.3 requires ext-curl * -> the requested PHP extension curl is …
Run Code Online (Sandbox Code Playgroud)

composer-php

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

如何在 svelte 中添加 Google Analytics 跟踪 ID

我想将我的Google Analytics Tracking ID-添加UA-XXXXXXXXX-X到我的 svelte 应用程序中。

我找到了两种方法。

第一次使用Install the global site tag 这里

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){window.dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'GA_MEASUREMENT_ID');
</script>

Run Code Online (Sandbox Code Playgroud)

我想,我必须将上面的代码插入到app.svelte. 我对吗?

二、使用@beyonk/svelte-google-analytics

使用安装包

npm i --save-dev @beyonk/svelte-google-analytics

import { GoogleAnalytics } from '@beyonk/svelte-google-analytics'

<GoogleAnalytics properties={[ 'google property id A', ...'google property id X' ]} />
Run Code Online (Sandbox Code Playgroud)

那么我应该在哪里添加呢tracking ID这就是 svelte 文档中 …

google-analytics svelte

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