最简单的是使用用户函数对数组进行排序,而无需任何循环:
以下是一个示例:
$array_compare= array("0" =>4,"1"=>2,"2"=>500,"3"=>100);
这将以截止的顺序排序:
usort($array_compare, function($a, $b) {
return ($b['x1'] - $a['x1']) > 0 ? 1 :-1;
});
这将按照申请顺序排序:
usort($array_compare, function($a, $b) {
return ($b['x1'] - $a['x1']) < 0 ? 1 :-1;
});
检查图像以查找罪魁祸首,
您可以更仔细地查看Docker图像,以找出哪些层占用了很多空间。要查看不同的层及其尺寸,您可以使用 Docker历史
命令。
示例:
docker history <image-name>
- stackoverflow上的相关问题
- href =“ https://docs.docker.com/engine/reference/commandline/history/” rel =“ nofollow noreferrer“> docker历史文档
方法获取较小图像
以改善图像大小的方法可以看待多阶段构建。
一个非常好的博客,展示了如何在Python中实现多阶段的构建并创建较小的图像和更快的构建:(博客由三篇文章组成)
- https://pythonspeed.com/articles/smaller-python-docker-images/
- https://pythonspeed.com/articles/multi-stage-docker-python/
- https://pythonspeed.com/articles/faster-multi-stage-builds/
就像@pierpy指出的那样,另一个改进是使用Python图像的高山文化。例如:
FROM python:3.9-alpine
请参阅所有图像版本在这里。
接口项目&gt;属性工具不是将版本从.NET标准更新为标准版本以外的其他版本的方式。正确/最简单的方法是直接在项目的.csproj文件中更新目标帧。
您似乎有很多不必要的嵌入在额外的视图和堆栈视图中...
看看:
这是该XIB的来源(取出空格,因此适合此答案):
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="w35-oq-szw">
<rect key="frame" x="0.0" y="0.0" width="745" height="531"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<visualEffectView opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="req-q9-lx2">
<rect key="frame" x="0.0" y="0.0" width="745" height="531"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" id="d1H-9Q-j7P">
<rect key="frame" x="0.0" y="0.0" width="745" height="531"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="sSl-mz-1DQ">
<rect key="frame" x="10" y="0.0" width="725" height="531"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="fGC-p9-L4U">
<rect key="frame" x="0.0" y="0.0" width="725" height="125.5"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="248" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="1fo-rx-txj">
<rect key="frame" x="0.0" y="0.0" width="137" height="125.5"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="7">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="JkP-z1-kBt">
<rect key="frame" x="147" y="0.0" width="137" height="125.5"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="8">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="aA8-sE-uyJ">
<rect key="frame" x="294" y="0.0" width="137" height="125.5"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="9">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="JdT-jT-0wO">
<rect key="frame" x="441" y="0.0" width="137" height="125.5"/>
<color key="backgroundColor" red="0.97410839800000004" green="0.8403052688" blue="0.2821659446" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="C">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="MqJ-SJ-vgm">
<rect key="frame" x="588" y="0.0" width="137" height="125.5"/>
<color key="backgroundColor" red="0.97410839800000004" green="0.8403052688" blue="0.2821659446" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="^">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="ryL-j9-8Gp">
<rect key="frame" x="0.0" y="135.5" width="725" height="125"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ATt-PW-v4y">
<rect key="frame" x="0.0" y="0.0" width="137" height="125"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="4">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="249" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ToS-iL-gQp">
<rect key="frame" x="147" y="0.0" width="137" height="125"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="5">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="248" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="OSw-U5-1GF">
<rect key="frame" x="294" y="0.0" width="137" height="125"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="6">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Uiw-M5-1xf">
<rect key="frame" x="441" y="0.0" width="137" height="125"/>
<color key="backgroundColor" red="0.97410839800000004" green="0.8403052688" blue="0.2821659446" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="-">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dHS-oz-6Ou">
<rect key="frame" x="588" y="0.0" width="137" height="125"/>
<color key="backgroundColor" red="0.97410839800000004" green="0.8403052688" blue="0.2821659446" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="/">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="JRw-LQ-aMf">
<rect key="frame" x="0.0" y="270.5" width="725" height="125.5"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="mal-m2-BW0">
<rect key="frame" x="0.0" y="0.0" width="137" height="125.5"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="1">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="KI1-ty-RLg">
<rect key="frame" x="147" y="0.0" width="137" height="125.5"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="2">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5EU-9l-FVK">
<rect key="frame" x="294" y="0.0" width="137" height="125.5"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="3">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="y6Q-JT-JWy">
<rect key="frame" x="441" y="0.0" width="137" height="125.5"/>
<color key="backgroundColor" red="0.97410839800000004" green="0.8403052688" blue="0.2821659446" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="+">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="G9r-jQ-QQ9">
<rect key="frame" x="588" y="0.0" width="137" height="125.5"/>
<color key="backgroundColor" red="0.97410839800000004" green="0.8403052688" blue="0.2821659446" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="x">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="Uw9-qZ-Dfo">
<rect key="frame" x="0.0" y="406" width="725" height="125"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8ld-d6-RQK">
<rect key="frame" x="0.0" y="0.0" width="137" height="125"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title=".">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="mBP-LN-MlY">
<rect key="frame" x="147" y="0.0" width="137" height="125"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="0">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="nde-Sc-JPt">
<rect key="frame" x="294" y="0.0" width="137" height="125"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="D">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dGq-08-Kzm">
<rect key="frame" x="441" y="0.0" width="284" height="125"/>
<color key="backgroundColor" red="0.97410839800000004" green="0.8403052688" blue="0.2821659446" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="=">
<fontDescription key="titleFontDescription" type="system" pointSize="40"/>
</buttonConfiguration>
</button>
</subviews>
</stackView>
</subviews>
<constraints>
<constraint firstItem="nde-Sc-JPt" firstAttribute="width" secondItem="5EU-9l-FVK" secondAttribute="width" id="4El-5L-MaG"/>
<constraint firstItem="mBP-LN-MlY" firstAttribute="width" secondItem="KI1-ty-RLg" secondAttribute="width" id="Htd-Ko-RcX"/>
<constraint firstItem="8ld-d6-RQK" firstAttribute="width" secondItem="mal-m2-BW0" secondAttribute="width" id="m9s-WZ-peK"/>
</constraints>
</stackView>
</subviews>
<constraints>
<constraint firstItem="sSl-mz-1DQ" firstAttribute="top" secondItem="d1H-9Q-j7P" secondAttribute="top" id="Db1-iD-Elh"/>
<constraint firstAttribute="trailing" secondItem="sSl-mz-1DQ" secondAttribute="trailing" constant="10" id="KbS-0k-Ie2"/>
<constraint firstItem="sSl-mz-1DQ" firstAttribute="leading" secondItem="d1H-9Q-j7P" secondAttribute="leading" constant="10" id="TJv-db-APH"/>
<constraint firstAttribute="bottom" secondItem="sSl-mz-1DQ" secondAttribute="bottom" id="g6s-Ye-LzN"/>
</constraints>
</view>
<blurEffect style="systemThinMaterial"/>
</visualEffectView>
</subviews>
<viewLayoutGuide key="safeArea" id="V0A-kF-WY5"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="req-q9-lx2" firstAttribute="leading" secondItem="V0A-kF-WY5" secondAttribute="leading" id="0fX-Cx-EME"/>
<constraint firstItem="req-q9-lx2" firstAttribute="trailing" secondItem="V0A-kF-WY5" secondAttribute="trailing" id="Jvp-Gw-hsl"/>
<constraint firstItem="req-q9-lx2" firstAttribute="top" secondItem="w35-oq-szw" secondAttribute="top" id="hrp-Zn-ETe"/>
<constraint firstAttribute="bottom" secondItem="req-q9-lx2" secondAttribute="bottom" id="kDe-Se-hCP"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="621" y="728"/>
</view>
</objects>
<resources>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
声明基于范围的作品,资源将在范围末尾处置,因此下一个:
public Stream GenerateReport()
{
using (var reportContext = new ReportRenderContext(this.ReportTemplate))
{
reportContext.Render();
}
return this.FileStream;
}
不是类似的to:
public Stream GenerateReport()
{
using var reportContext = new ReportRenderContext(this.ReportTemplate);
reportContext.Render();
return this.FileStream;
}
后一个类似于:
public Stream GenerateReport()
{
using (var reportContext = new ReportRenderContext(this.ReportTemplate))
{
reportContext.Render();
return this.FileStream;
}
}
在某些情况下可能会有所不同,因此由于该编译器不会产生警告(编译器非常聪明并且同时非常愚蠢,它并不“真正”知道什么 this.fileStream
这样做。 this.fileStream 将引入运行时错误或 this.fileStream
可以是一个相对较长的操作,并且 dispose
的主要目的之一就是将不需要它们,就会有“反向”示例href =“ https://stackoverflow.com/a/19103343/2501279”> async上下文)。
根据我们从评论中的讨论,您可以使用 value
内置函数[1]和的组合来实现所需的目标,而不是
而不是三元操作员:
resource "azuread_group" "groups" {
for_each = local.groups
display_name = each.key
security_enabled = true
assignable_to_role = true
members = [ for u in values(azuread_user.users) : u.id if u.department == each.key ]
}
[[[ 1] https://www.terraform.io/langueage/language/functions/functions/values
当我希望它与众不同时,我总是会获得相同的属性值。如果我直接称呼它,我每次都会收到随机结果...为什么会这样?
因为您是一次调用功能,并打印值4次。更确切地说,每次致电Rs.Value时,您都会获得不同的结果,并且您打电话一次并打印该值4次。
以下代码可能会帮助您
import random
import string
class RS:
def __init__(self, length: int):
self.N = length
@property
def value(self):
return ''.join(random.choice(string.ascii_uppercase + string.digits)
for _ in range(self.N))
class ABC:
def __init__(self, length: int):
self.N = length
self.rs = RS(self.N)
def print_times(self):
for i in range(4):
print(self.rs.value)
a = ABC(10)
a.print_times()
使用单个滤波器条件并使用
.distinctinct (…)
&nbsp; [django-doc]
返回不同的
dwcloudsystem
s:
from django.db.models import Q
DWCloudSystem.objects.filter(
Q(isShared=False, company_key=comp) |
Q(isShared=True, location__owners=comp)
).distinct()
对于我的实际数据集,我使用:
vars <- names(df)
num<- seq(3, length(vars)-1,1)
我从3开始启动序列,因为我有两个ID变量(是字符串)。
for (i in num ) {
df[paste0("d_", vars[i],"_",vars[i+1])]<-(df[,i+1]/df[,i]-1)
}
现在的问题是,我还计算了一个变量的最后一个阶段与下一个变量的第一个阶段之间的变化,因此我必须通过两个时期的组合删除这些列(在我的情况3&amp; 6)中:
df <- df %>% select(-c(contains("3") & contains("6")))
你的别名错了
Alias /static/ /home/pi/myproject/myprojectenv/myproject/static/
我知道您的问题正在处理输入。因此,您可以将它们作为字符串输入并将其转换为特定类型,例如:
import math
def get_sqrt(input_number: str) -> float:
"""Return square root of input_number if in the form "sqrt(number)" (e.g. sqrt(2))"""
value = float(input_number[input_number.find("(") + 1 : input_number.find(")")])
return math.sqrt(value)
def get_pi(input_number: str) -> float:
"""Return pi value if input_number in the form "pi" """
return math.pi
def get_division(input_number: str) -> float:
"""Return division value if input_number in the form "a/b" (e.g. 2/5)"""
value = float(input_number.split("/")[0]) / float(input_number.split("/")[1])
return value
def get_complex(input_number: str) -> complex:
"""Return complex value of input_number in the form "a+bj" (e.g. 1+2j)"""
return complex(input_number)
def get_correct_number(input_number: str):
str_patterns = {"sqrt": get_sqrt, "pi": get_pi, "/": get_division, "j": get_complex}
for str_pattern, func in str_patterns.items():
if str_pattern in input_number:
return func(input_number)
return float(input_number)
if __name__ == "__main__":
# If you want to fill your list of values
my_own_list = ["sqrt(2)", "pi", "1/2", "0", "4", "-4"]
my_values = []
print("Number -> Type")
for input_number in my_own_list:
number = get_correct_number(input_number)
print(number, "->", type(number))
my_values.append(number)
print("\nList of converted values: ")
print(my_values)
# If you want to input values manually
dont_stop = True
my_values = []
print("\nManual input\n")
while dont_stop:
input_number = input("Enter your number: ")
if input_number:
number = get_correct_number(input_number)
print("Number -> Type")
print(number, "->", type(number))
my_values.append(number)
else:
dont_stop = False
print("\nList of converted values: ")
print(my_values)
在这里,终端上输入/输出的一个例子:
Number -> Type
1.4142135623730951 -> <class 'float'>
3.141592653589793 -> <class 'float'>
0.5 -> <class 'float'>
0.0 -> <class 'float'>
4.0 -> <class 'float'>
-4.0 -> <class 'float'>
List of converted values:
[1.4142135623730951, 3.141592653589793, 0.5, 0.0, 4.0, -4.0]
Manual input
Enter your number: 1
Number -> Type
1.0 -> <class 'float'>
Enter your number: 1/4
Number -> Type
0.25 -> <class 'float'>
Enter your number: sqrt(3)
Number -> Type
1.7320508075688772 -> <class 'float'>
Enter your number: 3+5j
Number -> Type
(3+5j) -> <class 'complex'>
Enter your number:
List of converted values:
[1.0, 0.25, 1.7320508075688772, (3+5j)]
我希望这会有所帮助!
PS:我没有使用任何正格来评估空间(例如,加上空间的空间会导致例外),也没有试图涵盖常见的加薪异常。
您需要将字段从某些
Integerfield
更改为Chardfield
。数据库将整数+123
作为正数123
。You need to change field from some
IntegerField
toChardField
. Database treats integer+123
as simply positive number123
.而从excel导入,&#x2B;符号未插入数字字段,django