我需要通过 ClassName 获取元素,其开头为:
width-48 height-48 profile_view_img
完整标签:
<div class="width-48 height-48 profile_view_img_9131256"></div>
Run Code Online (Sandbox Code Playgroud)
这个班级的人数总是在变化。
这是我到目前为止所尝试过的:
var x = window.document.querySelectorAll("*[class^=\"width-48 height-48 profile_view_img\"]")[0]
Run Code Online (Sandbox Code Playgroud) 如何从字符串中仅提取应为"5"的最后一个数字?
var str = "1000040928423195 points added to your balance";
var str = parseInt(str);
var lastNum = str.substr(str.length - 1);
console.log(lastNum);
Run Code Online (Sandbox Code Playgroud) 我使用VSCODE作为编辑器,并且使用Python 3.7,我具有这种文件夹结构
project
|-- util
| -- drivers.py
| -- data.py
| -- __init__.py
|-- test
| -- driver_test.py
| -- __init__.py
main.py
Run Code Online (Sandbox Code Playgroud)
我想drivers.py从util文件夹导入到driver_test.py
我试图做这样的基本导入
from util.drivers import Driver
Run Code Online (Sandbox Code Playgroud)
由于找不到util模块而无法正常工作,然后我使用了另一种方法,在中添加了一个文件夹sys.path。像这样
# driver_test.py
sys.path.append(os.path.abspath('./util'))
import drivers
Run Code Online (Sandbox Code Playgroud)
我对几个输出错误感到非常困惑。当我从控制台运行单元测试时,出现错误,提示找不到驱动程序
import drivers
ModuleNotFoundError: No module named 'drivers'
Run Code Online (Sandbox Code Playgroud)
如果我通过右键单击在vscode编辑器中运行测试文件Run current test file,则错误输出是不同的,即找不到drivers.py文件中包含的硒驱动程序
from selenium import webdriver
ModuleNotFoundError: No module named 'selenium'
Run Code Online (Sandbox Code Playgroud)
Selenium模块实际上运行良好,我只想为此进行大多数单元测试。我做错了什么以及如何解决?并且可以包括模块而无需sys.path仅通过导入使用。
我开发了一个供公司内部使用的小型 Ui 组件,并将其发布到 npm,但是当我安装该包时,我只在文件夹index.js中获得一个文件node_modules。
我没有使用任何包生成器,es-modules,只是一个简单.js的.css
我想要作为包发布的文件夹具有以下结构:
package
- src
- index.js
- index.css
- assets/
- fonts/
- ..some fonts
- images/
- icon.svg
- package.json
Run Code Online (Sandbox Code Playgroud) 如何添加连接到移动垂直线的绿色阴影效果。
有关我的目标的示例,请参见图像。
如何在 CSS 中实现它?
这是我实施的示例
body {
height: 100vh;
position: relative;
}
.ocrloader p::before {
content: '';
display:inline-block;
width: 12px;
height: 12px;
border-radius: 50%;
background: #18c89b;
position: relative;
right: 4px;
}
.ocrloader p {
color: #18c89b;
position: absolute;
bottom: -30px;
left: 38%;
font-size: 16px;
font-weight: 600;
animation: blinker 1.5s linear infinite;
font-family: sans-serif;
text-transform: uppercase;
}
.ocrloader {
width: 360px;
height: 225px;
position: absolute;
left: 50%;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
top: 40%;
backface-visibility: hidden;
}
.ocrloader span {
position: …Run Code Online (Sandbox Code Playgroud)我一直在构建 Nodejs 应用程序,并想研究 Docker 容器内的项目。但是当我通过检查正在运行的容器时,bin/bash我无法/app在容器中找到目录
构建图像时没有显示错误
这是我的 docker 镜像文件
FROM node:15.7.0 as build-stage
WORKDIR /app
COPY package*.json /app/
RUN npm install
COPY ./ /app/
ARG configuration=production
RUN npm run build -- --output-path=./dist/out --configuration $configuration
FROM nginx:1.18
COPY --from=build-stage /app/dist/out/ /usr/share/nginx/html
COPY ./nginx-custom.conf /etc/nginx/conf.d/default.conf
Run Code Online (Sandbox Code Playgroud) 如何对以下值使用字典理解literals?list
现在我可以迭代嵌套字典并获得带有嵌套值的结果字典,但我想包含在输出dict、列表和文字(int,str)中
这是我的例子(我知道isinstance这里不需要)
nested_dict = {'first':{'a':1}, 'second':{'b':2}, 'third': 3, 'fourth': [1, 2, 3, 4]}
float_dict = {
outer_k: { float(inner_v)
for (inner_k, inner_v) in outer_v.items()}
for (outer_k, outer_v) in nested_dict.items()
if isinstance(outer_v, dict)
}
print(float_dict)
Run Code Online (Sandbox Code Playgroud)
预期输出:
{'first': {'a': 1.0}, 'second': {'b': 2.0}, 'third': 3.0, 'fourth': [1.0, 2.0, 3.0, 4.0]}
Run Code Online (Sandbox Code Playgroud) 我正在制作一个简单的脚本,使用 requests 和 BeatifulSoup 将单词从英语翻译成俄语,问题是结果框是空的,应该翻译单词/我不确定是否应该使用 GET 或 POST 方法。这是我尝试过的
with open('File.csv', 'r') as file:
csv_reader = csv.reader(file)
for line in csv_reader:
if line[1] == '':
url = 'https://translate.google.com/#en/ru/{}'.format(line[0])
r = requests.get(url, timeout=5)
soup = BeautifulSoup(r.content, 'html.parser')
translate = soup.find('span', id='result_box')
for word in translate:
print(word.find('span', class_=''))
Run Code Online (Sandbox Code Playgroud) 我在使用 PowerShell 脚本时遇到问题。我在运行时遇到错误
无法加载,因为该系统上禁用了运行脚本。有关详细信息,请参阅 https://go.microsoft.com/fwlink/?LinkID=135170 上的 about_Execution_Policies。
脚本未以管理员身份运行。
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
$arguments = "& '" + $MyInvocation.MyCommand.Definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
break
}
Set-ExecutionPolicy Bypass -Scope Process -Force
# Rest code
Run Code Online (Sandbox Code Playgroud)
似乎带有执行策略的行没有被执行。
命令
Set-ExecutionPolicy Unrestricted
Run Code Online (Sandbox Code Playgroud)
也没有帮助。
如果我使用了提取的图像网址,则需要获取宽度和高度get('width'),但这似乎不起作用
description = soup.find("div", id="module_product_detail")
img= description.find("img")
print(img.get('width'))
Run Code Online (Sandbox Code Playgroud)
输出为none。链接看起来像这样
<img alt="image" src="https://bos1.lightake.net:20011/UploadFiles/ShopSkus/1000x1000/Y2463/Y246302/sku_Y246302_1.jpg"/>
Run Code Online (Sandbox Code Playgroud) python ×4
javascript ×3
css ×1
dictionary ×1
docker ×1
npm ×1
npm-package ×1
npm-publish ×1
powershell ×1
selenium ×1