我要定义一个sum = 0
counter = 0
done = False
while not done:
integer_input = int(input("Please enter a number."))
if counter < 9:
counter += 1
sum = sum+integer_input
else:
done = True
print("The average of your numbers is:", sum/10,"The minimum of your numbers is:" "The maximum of your numbers is:")
属性,并使用它来驱动其他几个属性的值,如下所示:
Timestamp
在我的一项任务中,我吐出了 <PropertyGroup>
<TrapHouseBuildToolsPath>..\TrapHouse.Build.NetStandard\bin\$(Configuration)\netstandard2.0\publish\TrapHouse.Build.NetStandard.dll</TrapHouseBuildToolsPath>
<Timestamp>$([System.DateTime]::Now.ToUniversalTime()))</Timestamp>
<DeploymentEnvironment>LOCALDEV</DeploymentEnvironment>
<TrapHouseVersion>$(DeploymentEnvironment)$([System.String]::Format("{0:yyyyMMddHHmmss}", Timestamp)</TrapHouseVersion>
</PropertyGroup>
的值,这不是我期望的值:
TrapHouseVersion
很明显我没有正确使用语法,但是我很难找到这类东西的好资源。
我需要怎么做才能使4.5.0-LOCALDEV$([System.String]::Format("{0:yyyyMMddHHmmss}", Timestamp)
得到正确的评估?
答案 0 :(得分:1)
首先,您在结尾处缺少右括号,但还知道该属性不会持久存储为DateTime
,而属性仅存储为字符串,因此您不能使用String.Format
稍后(除了再次将$(Timestamp)
解析为DateTime
之外):
<Project DefaultTargets="PrintVersion">
<PropertyGroup>
<Timestamp>$([System.String]::Format("{0:yyyyMMddHHmmss}", $([System.DateTime]::Now.ToUniversalTime())))</Timestamp>
<DeploymentEnvironment>LOCALDEV</DeploymentEnvironment>
<TrapHouseVersion>$(DeploymentEnvironment)$(Timestamp)</TrapHouseVersion>
</PropertyGroup>
<Target Name="PrintVersion">
<Message Importance="high" Text="TrapHouseVersion: $(TrapHouseVersion)" />
</Target>
</Project>
运行时:
$ dotnet msbuild
Microsoft (R) Build Engine version 15.8.169+g1ccb72aefa for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
TrapHouseVersion: LOCALDEV20181012171759