它适用于for循环和可变变量:
let addLnNum filename =
use outFile = new StreamWriter(@"out.txt")
let mutable count = 1
for line in File.ReadLines(filename) do
let newLine = addPre (count.ToString()) line
outFile.WriteLine newLine
count <- count + 1
Run Code Online (Sandbox Code Playgroud)
但它非常"无功能",所以我很好奇这样做的正确方法是什么?我想到如何将索引号附加到字符串列表:
let rec addIndex (startInd:int) l=
match l with
|x::xs -> startInd.ToString()+x :: (addIndex (startInd+1) xs)
|[] -> []
Run Code Online (Sandbox Code Playgroud)
但它不适用于File.ReadLines:
let addLnNum2 filename =
use outFile = new StreamWriter(@"out.txt")
File.ReadLines(filename)
|> addIndex 1
|> ignore
//Error 1 Type mismatch. Expecting a Collections.Generic.IEnumerable<string> -> 'a
//but given a …Run Code Online (Sandbox Code Playgroud) 我想连接到数据库(Oracle 12c)以生成ADO.NET模型,“从数据库中优先获取代码”。我已经安装了VS的ODAC,但是在实体数据模型向导中仍然没有连接Oracle DB的选项:

在服务器资源管理器中有一个Oracle提供程序,但已被弃用:

我还尝试安装以下4个Nuget软件包,但在实体数据模型向导中仍然没有Oracle提供程序:

我怀疑VS2017(Community)不在为它使用的提供程序列表查看ODAC的安装位置,但是我无法确定它在哪里存储此配置。
有什么我想念的吗?还是有其他方法可以将EF用于Oracle?例如回退到VS2015,手动创建实体模型(我该怎么做?),等等。
请帮助我,我不想再用代码编写普通的SQL!谢谢。
所以我在 csv 文件中有一些训练数据,train.csv格式如下:
x;y;type
[1,2,3];[2,3,4];A
[2,7,9];[0,1,2];B
Run Code Online (Sandbox Code Playgroud)
该文件被解析为pd.DataFrame以下内容:
CSV_COLUMN_NAMES = ['x', 'y', 'type']
train = pd.read_csv("train.csv", names=CSV_COLUMN_NAMES, header=0, delimiter=";")
train['x'] = train['x'].apply(literal_eval)
train['y'] = train['y'].apply(literal_eval)
Run Code Online (Sandbox Code Playgroud)
到目前为止,一切都很好。该literal_eval函数如此应用x并被y视为数组。下一步是DataSet使用以下内容创建一个:
features, labels = train, train.pop('type')
dataset = tf.data.Dataset.from_tensor_slices((dict(features), labels))
Run Code Online (Sandbox Code Playgroud)
这就是它崩溃的地方:(它会溢出以下错误:
TypeError: Expected binary or unicode string, got [1, 2, 3]
Run Code Online (Sandbox Code Playgroud)
为什么需要二进制或 unicode 字符串?不允许向量特征列吗?或者我做错了什么?请给我一些启发
我有一个函数(表单中的事件处理程序)结构如下:
Dim errMsg as String = ""
CheckIfValidUser(..., errMsg)
If errMsg.Length > 0 Then
ShowError(errMsg)
LogError(errMsg)
Return
End If
CheckIfBookAvailable(..., errMsg)
If errMsg.Length > 0 Then
ShowError(errMsg)
LogError(errMsg)
Return
End If
ReserveBook(..., errMsg)
If errMsg.Length > 0 Then
ShowError(errMsg)
LogError(errMsg)
Return
End If
BookReserved = True
Run Code Online (Sandbox Code Playgroud)
我注意到大多数代码都是类似的结构,所以我尝试重构如下:
Dim errMsg as String = ""
Dim HandleError = Sub()
If errMsg.Length > 0 Then
ShowError(errMsg)
LogError(errMsg)
Return
End If
End Sub
CheckIfValidUser(..., errMsg)
HandleError()
CheckIfBookAvailable(..., errMsg)
HandleError()
ReserveBook(..., errMsg)
HandleError()
BookReserved = …Run Code Online (Sandbox Code Playgroud) 我是新来的Spring MVC和我跟着入门指南导入hello web应用程序(Service Web Content在春季工具套件).它作为使用嵌入式Tomcat servlet的独立应用程序非常有用.
然后我继续将应用程序打包为战争.采取的实际步骤如下:
SpringBootServletInitializer并添加SpringApplicationBuilder配置方法.provided.war.出口和部署GS-服务,网络化内容initial.war到JBoss AS 7后,但是我无法找到一种方法来访问应用程序!
双方http://localhost:8080/greeting并http://localhost:8080/gs-serving-web-content-initial/greeting给出了同样的404 The requested resource (/greeting) is not available..(之前使用结构构建的另一场战争经过测试可以在同一个jboss上正常工作)
添加jboss-web.xml也不起作用.那我错过了什么?
更新20151217:
相关的JBoss日志如下所示.警告(JBAS011006)在部署战争时显示,但春季战争似乎正常?
09:06:06,107 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "gs-serving-web-content-initial.war"
09:06:06,970 WARN [org.jboss.as.ee] (MSC service thread 1-2) JBAS011006: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to exception: org.jboss.as.server.deployment.DeploymentUnitProcessingException: …Run Code Online (Sandbox Code Playgroud) 我创建了一个托盘应用程序来控制一些硬件组件。如何在没有主窗体或控件的情况下调用 UI 线程?
托盘应用程序的启动方式为Application.Run(new MyTrayApp()):
class MyTrayApp : ApplicationContext
{
private NotifyIcon trayIcon;
public MyTrayApp()
{
trayIcon = new NotifyIcon()
{
Icon = Resources.app_icon,
ContextMenu = new ContextMenu(new MenuItem[] {
new MenuItem("Exit", Exit)
}),
Visible = true
};
// context is still null here
var context = SynchronizationContext.Current;
// but I want to invoke UI thread in hardware events
MyHardWareController controller= new MyHardWareController(context);
}
void Exit(object sender, EventArgs e)
{
// context is accessible here because this is …Run Code Online (Sandbox Code Playgroud)