简单地说,我一直在努力实现BufferedStreamReaderJava中的功能.我打开了一个套接字流,只想逐行地逐行读取它.
我有以下服务器代码.
while (continueProcess)
{
try
{
StreamReader reader = new StreamReader(Socket.GetStream(), Encoding.UTF8);
string command = reader.ReadLine();
if (command == null)
break;
OnClientExecute(command);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
Run Code Online (Sandbox Code Playgroud)
以下客户端代码:
TcpClient tcpClient = new TcpClient();
try
{
tcpClient.Connect("localhost", serverPort);
StreamWriter writer = new StreamWriter(tcpClient.GetStream(), Encoding.UTF8);
writer.AutoFlush = true;
writer.WriteLine("login>user,pass");
writer.WriteLine("print>param1,param2,param3");
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
finally
{
tcpClient.Close();
}
Run Code Online (Sandbox Code Playgroud)
服务器只读取第一行(login>user,pass)然后ReadLine返回null!
实现这种面向行的读者的最简单方法是什么,就像在Java中一样BufferedStreamReader?:■
我的JSON字符串包含一个返回这样一个值的日期字段:
"2009-04-04T22:55:16.0000000-04:00"
Run Code Online (Sandbox Code Playgroud)
我特别感兴趣的是只解析日期隔间而不是时间.我尝试使用reviver函数,但有趣的是,从不调用reviver函数!(在Firefox上试过)
这是我完成的代码:
var Site = {
.....
dateReviver: function(key, value) {
var a;
if (typeof value === 'string') {
a = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
if (a) {
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+a[5], +a[6]));
}
}
return value;
},
loadArticle: function(id) {
....
proxy.getArticle(id, function(response) {
var data = JSON.parse(response.result, Site.dateReviver);
....
});
}
};
Run Code Online (Sandbox Code Playgroud)
loadArticle永远不会调用JSON.parse dateReviver.
我投了一整天但没有运气!有人可以帮帮我吗?
我一直在windows-msysgit上使用git.每当我尝试使用资源管理器或使用时完全删除存储库
$ git rm -rf ptp/
fatal: Not a git repository (or any of the parent directories): .git
Run Code Online (Sandbox Code Playgroud)
它出错"重新分析点缓冲区中存在的数据无效"或上面的致命错误.
我/ git有什么问题?
提前致谢
我正在阅读django dev文档.这里说它不再推荐永久链接装饰器,在你的get_absolute_url方法中使用反向为模型实例生成完整的URL(滚动一点上面并查看警告框).
我认为它违反DRY,我们必须在每次需要时使用反向.那么使用固定链接有什么问题?为什么不再推荐?
我在 spring-ws 中使用 DynamicWsdl11Definition 来生成我的 wsdl 规范。最终,我得到了一个没有附加到 wsdl 操作的 wsdl 错误的规范,因为我不知道如何自动将特定的 wsdl/soap 操作与特定的 wsdl 错误关联起来。我怎样才能做到这一点?有没有办法将 wsdl 错误与 XSD 模式中的 wsdl 操作相关联?
这是我的 XSD 的一部分:
<xs:element name="setContextRequest">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="usageContext" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="setContextResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Run Code Online (Sandbox Code Playgroud)
这是我的例外:
<xs:element name="InvalidSessionException">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="InvalidSessionException" nillable="true" type="fault:InvalidSession"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Run Code Online (Sandbox Code Playgroud)
这是 WSDL 规范:
<wsdl:operation name="setContext">
<soap:operation soapAction=""/>
<wsdl:input name="setContextRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="setContextResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
Run Code Online (Sandbox Code Playgroud)
我的问题是如何将错误与该操作相关联,最终以: …
我正在尝试使用sbt-scalabuff插件,但是sbt一直在抱怨无法找到该插件.
插件文档也没有说明解析器URL.该插件是否已弃用或我的Scala版本不受支持?
细节:
com.github.sbt:sbt-scalabuff:0.2 (sbtVersion=0.13, scalaVersion=2.10)
Run Code Online (Sandbox Code Playgroud)
这是我的plugins.sbt:
libraryDependencies += "net.sandrogrzicic" %% "scalabuff-runtime" % "1.3.6"
addSbtPlugin("com.github.sbt" %% "sbt-scalabuff" % "0.2")
Run Code Online (Sandbox Code Playgroud)
这是堆栈跟踪的一部分:
sbt.ResolveException: unresolved dependency: com.github.sbt#sbt-scalabuff;0.2: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:213)
at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:122)
at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:121)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:116)
at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:116)
at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:104)
at sbt.IvySbt.sbt$IvySbt$$action$1(Ivy.scala:51)
at sbt.IvySbt$$anon$3.call(Ivy.scala:60)
...
[error] (*:update) sbt.ResolveException: unresolved dependency: com.github.sbt#sbt-scalabuff;0.2: not found
Run Code Online (Sandbox Code Playgroud) 我有一个python模块,m1.
# m1.py
class C1(object):
def __init__(self):
self.__pri = 10
self._pro = 5
self.pub = 1
Run Code Online (Sandbox Code Playgroud)
然后在bpython中,
>>> import m1
>>> c = m1.C1()
>>> c.__pri
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: 'C1' object has no attribute '__pri'
>>> c._pro
5
>>> c.pub
1
>>> dir(c)
['_C1__pri', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_pro', 'pub']
>>> c._C1__pri
10
Run Code Online (Sandbox Code Playgroud)
我以为python中没有私有变量的概念.我们现在如何解释这种行为?
编辑:我本来期待直接访问c .__ pri,但事实证明这 …