只需将返回
用产量
替换。
def itercolumn(names):
for i in names:
result = i[-2:]
if result == "16":
yield i
print(list(itercolumn(names)))
或者
def itercolumn(names):
final = []
for i in names:
result = i[-2:]
if result == "16":
final.append(i)
return final
print(itercolumn(names))
您可以使用列表理解
result = [name for name in names if name[-2:] == '16']
好吧,您实际上在不仔细观察的情况下回答了自己的问题。
让我向您展示原因:
set command="C:\Program Files\7-Zip\7z.exe" l "FolderName\archive.zip" "file.cmd"
for /F "delims=" %%a in ('"%command%"') do ...
请注意,您的代码将set
命令的值转换为:
"C:\Program Files\7-Zip\7z.exe" l "FolderName\archive.zip" "file.cmd"
您在哪里将其传递给循环,以double引号,例如:
"%command%"
最终将是:
""C:\Program Files\7-Zip\7z.exe" l "FolderName\archive.zip" "file.cmd""
它将完全工作在for循环中:
for /f "delims=" %%i in ('""C:\Program Files\7-Zip\7z.exe" l "FolderName\archive.zip" "file.cmd""') do ...
尽管在这种情况下,这将按预期工作,但如果您的引用字符串包含特殊字符,则如&
,如本示例所示:
for /f "delims=" %%i in ('""C:\Program Files\7-Zip\7z.exe" l "FolderName\archives & backups.zip" "file.cmd""') do ...
因此,您需要简单地逃脱外部双重引号要克服这一点:
for /f "delims=" %%i in ('^""C:\Program Files\7-Zip\7z.exe" l "FolderName\archives & backups.zip" "file.cmd"^"') do ...
您应该能够使用
获得您需要的东西。dateTime.parseexact.parseexact
DateTime.ParseExact("203658.000", "HHmmss.fff", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal)
不过,请在午夜左右小心,因为如果日期不匹配,时间可能会近24小时。
为了使您获取信息,每个输入必须具有“名称”属性。如下:
<form action="https://formsubmit.co/[email protected]" method="POST">
<input type="text" name="name" required>
<input type="email" name="email" required>
<button type="submit">Send</button>
</form>
另外,将输入从无序列表中取出。
使用
mysql -h 127.0.0.1 -D db_name -u username --password=pass --debug-info true shared/local_sql/3.sql
您可能复制字符&lt;
和&gt;
从某个示例中使用这些字符指示文件名的占位符,例如mysql ...&lt ; sql_file&gt;
。
整个占位符&lt; sql_file&gt;
必须用shared/local_sql/3.sql/3.sql
在示例中替换为实际文件名。
字符&lt;
和&gt;
被外壳解释为标准输入或标准输出的重定向。
&lt; shared/local_sql/3.SQL
指示Shell从指定文件重定向mySQL
命令的标准输入。这实际上可能起作用。
&gt;
需要一个文件名来指定应将输出重定向到何处。由于没有文件名,但是行的结尾,您会收到错误消息。
考虑以下内容。
$(function() {
$(".getPtsValue").each(function(i, el) {
var point = parseInt($(el).text().trim());
if (point == 0) {
$(el).addClass("red");
} else if (point > 100) {
$(el).addClass("blue");
}
});
});
.red {
color: red;
}
.blue {
color: blue;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<span class="getPtsValue">20</span>
<span class="getPtsValue">0</span>
<span class="getPtsValue">225</span>
<span class="getPtsValue">100</span>
<span class="getPtsValue">0</span>
<span class="getPtsValue">60</span>
这使用.each()
,它将迭代每个元素。
描述:在jQuery对象上迭代,为每个匹配元素执行一个函数。
为了确保我们将数字与数字进行比较。当我们获得.html()
或.text()
时,它将是字符串。我们可以使用parseint()
将其作为整数施放。
然后,我们使用.addclass()
将类名添加到元素中。这可以是您想要的任何值,我只使用red
和蓝色
。
这是下面的工作片段。我已经做到了,以便它每0.5秒过渡一次,以便您可以更快地看到它。如果您需要5秒钟,请将间隔更改为5000而不是500。
通常,SetInterval在班级中的工作方式与外部没有不同。您只需要注意this
绑定(即,如果您做过setInterval(this.transitionslide,5000)
,这将无法正常工作,因为 this 将失去范围,因此.bind(this)
)
要注意的关键内容:
您想跟踪setInterval的返回值,这是一个间隔ID。这将使您停止间隔不断发生。
我们现在有2个函数 - startlideshow和stopslideshow,当您实例化新的
Gallery
时,您应在实例变量上使用.startslideshow()
开始。当您需要使用
items.length
时,您正在使用list.length
,因为这是跟踪各个幻灯片的方法。
const list = document.querySelector('.js-gallery');
const items = document.querySelectorAll('.gallery__item'); // Use this for slide count, not list
Array.from(list); // Doesn't do anything
class Gallery {
constructor(slideshow) {
this.slideshow = slideshow;
this.slideCount = items.length;
this.items = items[0].getBoundingClientRect().width;
this.currentSlide = 1;
this.slideTransitionInterval = null;
}
transitionSlide() {
console.log('invoked');
if (this.currentSlide < this.slideCount) {
list.style.transform = `translateX(-${this.currentSlide * this.items}px)`;
this.currentSlide += 1;
} else {
this.stopSlideshow();
list.style.transform = `translateX(0)`;
this.currentSlide = 1;
}
}
// Trying to make a method with setInterval() so that the slide runs every 5 seconds.
startSlideshow() {
this.stopSlideshow();
this.slideTransitionInterval = setInterval(this.transitionSlide.bind(this), 500);
}
stopSlideshow() {
if (this.slideTransitionInterval) {
clearInterval(this.slideTransitionInterval);
}
}
}
const pics = new Gallery(list);
pics.startSlideshow();
.title {
width: 100%;
text-align: center;
}
.gallery {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
padding: 0;
transition: all 500ms ease;
}
.gallery-container {
overflow: hidden;
position: relative;
width: 1000px;
margin: 0 auto;
}
.gallery__item {
list-style: none;
height: 500px;
min-width: 1000px;
background-position: center center;
background-size: cover;
}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body>
<h1 class="title">Gallery of Real Cool JS3 Images</h1>
<div class="gallery-container">
<ul class="gallery js-gallery">
<li class="gallery__item js-gallery-item" style="background-image: url('https://picsum.photos/1000/650/?image=1062')"></li>
<li class="gallery__item js-gallery-item" style="background-image: url('https://picsum.photos/1000/650/?image=837')"></li>
<li class="gallery__item js-gallery-item" style="background-image: url('https://picsum.photos/1000/650/?image=1025')"></li>
<li class="gallery__item js-gallery-item" style="background-image: url('https://picsum.photos/1000/650/?image=237')"></li>
</ul>
</div>
<script src="script.js" defer></script>
</body>
</html>
tl; dr 为了使圣所起作用,服务器和客户端必须在同一顶级域上,不同的端口还可以。对于使用圣所的本地开发,localhost
是最简单的解决方案,如 lar noreferrer“> laravel breeze 建议包装。
假设您正在端口8080
上运行前端,然后在端口8000
上进行后端。
- 在
.env
中
APP_URL=http://localhost:8000
FRONTEND_URL=http://localhost:8080
config/sanctum.php
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
'%s%s%s',
'localhost,localhost:8080,127.0.0.1,127.0.0.1:8000,::1',
env('APP_URL') ? ','.parse_url(env('APP_URL'), PHP_URL_HOST) : '',
env('FRONTEND_URL') ? ','.parse_url(env('FRONTEND_URL'), PHP_URL_HOST) : ''
))),
注意以上示例中的端口8080和8000
- 请
php artisan config:cache
。正确,只需检查上面的两个配置,然后将其他配置转换为默认情况。
不,在调用暂停
改造和房间的功能时,您无需切换上下文。我不确定他们是否在引擎盖下使用dispatcher.io
,也许他们使用由线程池组成的自定义上下文,但可以保证在背景线程中调用。
例如,您可以在viewModel
类中呼叫susthend
dao函数类似:
viewModelScope.launch {
val user dao.getCurrentUser()
// Update UI using user
}
假设getCurrentUser()
as susth 功能:
suspend fun getCurrentUser(): User
Typescript具有 enum type -type -type
enum ViewDirection {
Horizontal = "Horizontal",
Down = "Vertical",
}
-from typescript文档:
在现代打字稿中,当对象具有AS时,您可能不需要枚举
const可能就足够:
因此,您可以做:
const ViewDirection = {
Horizontal = "Horizontal",
Down = "Vertical",
} as const;
vs字符串类型
如果字符串的值发生更改,则使用字符串 - 启动器仅表示1个字符串,而使用字符串式式型字符串表示,则意味着更改它们到处使用。
用外行术语,您可以将Horizontal =“ Horizontal”
更改为horizontal =“ H”
,而无需在使用字符串枚举时到处更改它。
此处的更多深入:
TS 类型
我发现,没有任何方法可以与近孔一起使用:isempty()
或keyset()
始终不会返回连接,因为这些方法不是proxy-object方法。因此,我可以在此处使用getall()
get()方法。
通常,浏览器将阻止您编辑硬盘驱动器上的任何文件的内容,或者从另一个域/基本URL提供的任何页面。但是,如果两个文件都在与下面所示的同一项目中,则可以从另一个文件进行临时编辑;
/http
|-index.html
|-template.html
|-hello.png
index.html
可以包含a &lt; script&gt;
标记以下标签,
// first we open a popup showing the other page
let window_template = open("template.html","_blank")
// now we can do whatever we want in the popup window from the original index.html:
let new_img = window_template.document.createElement("img")
new_img.src = "hello.png"
window_template.document.body.appendChild(new_img)
这不会(也不能)将任何更改保存到“ Template.html”。
要实际更改文件,您需要运行自己的服务器。然后,index.html可以将请求发送到服务器,并且服务器将有能力代表基于浏览器的应用程序进行编辑。查看Node.js和Express Server库...我发现随着服务器框架的发展,它足够接近。
在入门 f for Mongoose的页面上> mongoose.model():
On the Getting Started page for mongoose, it indicates that methods must be declared before calling
mongoose.model()
:在Mongoose中,我执行了网站中给出的示例程序,但是我得到的错误与以下相同的错误:typeError:fluffy.speak不是一个函数