import math
def main():
StrFileName = input('Enter a File')
inFile = open(StrFileName, 'r')
intLines = 0
for i in open(StrFileName, 'r'):
intLines = intLines + 1
intTotalLines = intLines
intID = 0
intAmt = 0
intIncome = 0
State = 0
for i in range(intTotalLines):
line = inFile.readline()
intID, intAmt, intIncome, State = line.split()
Line = [intID, intAmt, intIncome, State]
Income = int(intIncome)
print(sum(Income))
main()
Run Code Online (Sandbox Code Playgroud)
我int object is not iterable试图转换intIncome成一个int(线分割自动使它成为一个字符串)时不断收到消息.提前感谢您的帮助!
我正在尝试将一些 C# 代码翻译成 java,并且想知道 java 的等价物是什么System.Convert.ToInt32(char):
将指定 Unicode 字符的值转换为等效的 32 位有符号整数。
Convert.ToInt32(letter);
Run Code Online (Sandbox Code Playgroud) 我有打电话的问题Close()或Dispose()上MessageQueue。我有一个应该能够管理这些消息队列的应用程序。打开和关闭它们。
但是当我打电话时Close()还是Dispose()什么也没有发生。队列仍然存在于机器上。我使用该MessageQueue.GetPrivateQueuesByMachine()方法获取MessageQueue's的数组,并且在调用Close()or后它仍然在那里Dispose()。经过一番阅读后,似乎Dipose()应该是我使用的那个,但仍然如此。
这是我用来尝试关闭队列的代码
public String CloseQueue(String path)
{
if (GetQueueArray().Length == 0)
{
return "The Queue Array is Empty!";
}
foreach (MessageQueue m in GetQueueArray())
{
if (m.Path.Equals(path))
{
try
{
path = m.QueueName;
m.Close();
break;
}
catch (Exception e)
{
return e.Message;
}
}
}
return "Successfully Closed Queue at path: " + path;
}
Run Code Online (Sandbox Code Playgroud)
该方法GetQueueArray()定义为(在同一类中):
public …Run Code Online (Sandbox Code Playgroud) 我想验证证书密码。此时我有基于处理 CryptographicException 和检查异常消息的代码。但这种方法取决于英语文化信息。
public bool VerifyPassword(byte[] fileContent, string password)
{
try
{
var certificate = new X509Certificate2(fileContent, password);
}
catch (CryptographicException ex)
{
if (ex.Message.StartsWith("The specified network password is not correct."))
{
return false;
}
throw;
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
我一直在寻找如何验证证书密码的其他解决方案,但没有成功。
如何验证证书密码的正确方法是什么?
我很感激任何想法......
这适用于Java 1.7,但不适用于1.6.(这是使用Guava 14.0.1).
Cache<TokenCacheKey, CachedToken>tokenCache = CacheBuilder.<TokenCacheKey, CachedToken>from(PARAM.tokenCacheConfig).build();
Run Code Online (Sandbox Code Playgroud)
任何人都可以提出可以在1.6中编译的替代方案吗?
我最近继承了这个SQL:
TRUNCATE TABLE [tb_Whitelist]
--DECLARE @Counter INT, @Max INT
SELECT @Counter = 10000000
SELECT @Max = 19999900
WHILE @Counter <= @Max
BEGIN
INSERT [tb_Whitelist] ([AvailableId]) VALUES(@Counter)
SELECT @Counter = @Counter + 1
END
Run Code Online (Sandbox Code Playgroud)
这需要7个小时才能运行,我被告知这个时间太慢了.是否有任何其他批量插入策略可以让我更快地插入一堆连续数字,或者我可以做些什么来使这个更快地运行?
我没有得到答案(立方体的体积)
它不断回来0.0作为答案,我无法弄清楚我做错了什么.为什么volume()方法实际上不是乘以cubeSide?
import java.util.Scanner;
class Cube{
private double cubeSide;
private double volumeAnswer;
//default const
public Cube(){
cubeSide = 0;
}
//argument constructor
public Cube(double inp){
cubeSide = inp;
}
//method for volume
public void volume(){
volumeAnswer = cubeSide * cubeSide * cubeSide;
}
//returning value
public double returnIt(){
return volumeAnswer;
}
}//end of class cube
public class myCubeClass{
public static void main(String[] args){
/*
Cube class
- Two constructors (one default and the other …Run Code Online (Sandbox Code Playgroud) 给定一个方法需要在每次调用时使用当前日/月/年的值,并且每秒调用几次(数百万次或更多次),除了创建一个Calendar对象之外,还有更快的方法来实现该功能吗?每次调用的当前时间?
使用Calendar.getInstance()或calendar.setTime()(使用时间字段重新计算)每秒执行多次是非常昂贵的.
标准Java解决方案是优选的(例如,超过使用第三方库).
When i try to add a migration, "k" gives me the following error:
k : System.Exception: Unable to locate project.json
At line:1 char:1
+ k web
+ ~~~~~
+ CategoryInfo : NotSpecified: (System.Exceptio...te project.json:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
bij Microsoft.Framework.Runtime.DefaultHost.Initialize(DefaultHostOptions options, IServiceProvider hostServices)
bij Microsoft.Framework.Runtime.DefaultHost..ctor(DefaultHostOptions options, IService
Provider hostServices)
bij Microsoft.Framework.ApplicationHost.Program.Main(String[] args)
Run Code Online (Sandbox Code Playgroud)
Here is my global.json:
{
"projects": [ "src", "FoodDelivery" ],
"sdk": {
"version": "1.0.0-beta4"
}
}
Run Code Online (Sandbox Code Playgroud)
I have the following directory structure
FoodPick
FoodPick/src
FoodPick/src/FoodDelivery
FoodPick/src/FoodDelivery/project.json …Run Code Online (Sandbox Code Playgroud) 我可以<a href='/Area/Controller/action'> </a>
在asp.net vnext中使用,但只是想知道我们是否可以使用标记助手
<a asp-controller="ControllerName" asp-action="ActionName" asp-area="AreaName">来重定向到该区域中的特定文件.
是否有人会指导我如何使用标签助手重定向到区域中的文件.
java ×4
asp.net-mvc ×2
c# ×2
.net ×1
asp.net-core ×1
calendar ×1
certificate ×1
dispose ×1
generics ×1
geometry ×1
guava ×1
java-6 ×1
math ×1
msmq ×1
python ×1
razor ×1
sql-server ×1
tag-helpers ×1
time ×1