是否有适用于Scala的Play Framework 2的脚手架生成器实用程序,如Ruby on Rails?我找到了一些关于这方面的话题,但没有弄清楚哪一个最受欢迎,或者哪个是最标准的?
你的意见?
更新:我的意思是脚手架用于生成控制器,视图,模型或其中任何一个.
我以这种方式检索XML文档:
import xml.etree.ElementTree as ET
root = ET.parse(urllib2.urlopen(url))
for child in root.findall("item"):
a1 = child[0].text # ok
a2 = child[1].text # ok
a3 = child[2].text # ok
a4 = child[3].text # BOOM
# ...
Run Code Online (Sandbox Code Playgroud)
XML看起来像这样:
<item>
<a1>value1</a1>
<a2>value2</a2>
<a3>value3</a3>
<a4>
<a11>value222</a11>
<a22>value22</a22>
</a4>
</item>
Run Code Online (Sandbox Code Playgroud)
我如何检查a4
(在这种特殊情况下,但它可能是任何其他元素)是否有孩子?
我使用brew在mac上安装了postgresql.在安装过程中我没有被问及postgresql的密码.现在我需要创建一个用户而不能:
Alexs-MacBook-Air:mydir alex$ su - postgres
Password:
su: Sorry
Run Code Online (Sandbox Code Playgroud)
无论我使用什么密码(包括空),都是错的.重置它的最简单方法是什么?
我收到一个错误there were 15 feature warning(s); re-run with -feature for details
:
$ /usr/local/sbt/bin/sbt
[info] Loading project definition from /home/alex/Documents/projects/my_app123/project
[info] Set current project to sbt-android (in build file:/home/alex/Documents/projects/my_app123/)
> compile -feature
[error] Expected end of input.
[error] compile -feature
[error] ^
> sbt-version
[info] 0.12.4
> compile
[warn] Credentials file /home/alex/.ivy2/.credentials does not exist
[info] Compiling 20 Scala sources to /home/alex/Documents/projects/my_app123/target/scala-2.10/sbt-0.12/classes...
[error] there were 15 feature warning(s); re-run with -feature for details
[error] one error found
[error] (compile:compile) Compilation …
Run Code Online (Sandbox Code Playgroud) 我想知道,这两者之间有什么区别:
val a = 123
println(f"hello1 $a") // 1
println(s"hello1 $a") // 2
Run Code Online (Sandbox Code Playgroud) 这很好用
class MyClass[T<: Actor: ClassTag] extends Actor {
//....
}
Run Code Online (Sandbox Code Playgroud)
但这不是由于错误 No ClassTag available for MyClass.this.T
class MyClass extends Actor {
type T<: Actor
//...
}
Run Code Online (Sandbox Code Playgroud)
即使执行以下操作:
class MyClass extends Actor {
type T<: Actor: ClassTag //this doesn't even compile
//...
}
Run Code Online (Sandbox Code Playgroud)
我如何使用摘要type
并摆脱错误?
setup.py
我发送到pip的Python包中的文件:
#!/usr/bin/env python
from distutils.core import setup
setup(
#......
long_description=open('README.md').read(),
#....
)
Run Code Online (Sandbox Code Playgroud)
该文件README.md
存在.将断点放入setup.py
并在本地执行时,它会很好地读取文件.但是,当我从pip(pip install my_lib
)安装它时,它会在安装过程中抛出一个异常:
File "/private/var/folders/ty/0nvksfhn29z_cjb6md2t3x8c0000gn/T/pip_build_alex/my_app123/setup.py", line 14, in <module>
long_description=open('README.md').read(),
IOError: [Errno 2] No such file or directory: 'README.md'
Complete output from command python setup.py egg_info:
Run Code Online (Sandbox Code Playgroud)
更新:
我刚刚从pip下载了我的库,解压缩并发现文件README,LICENSE,MANIFEST不在其中.他们在gitignore也是因为他们存在于github.
我有一个类,我希望能够转换为json:
case class Page[T](items: Seq[T], pageIndex: Int, pageSize: Int, totalCount: Long)
object Page {
implicit val jsonWriter: Writes[Page[_]] = Json.writes[Page[_]]
}
Run Code Online (Sandbox Code Playgroud)
错误是 No apply function found matching unapply parameters
我想使用列的索引(数字)执行选择.我试过了:
select 1 from "user"
select '1' from "user"
Run Code Online (Sandbox Code Playgroud)
但他们不按我的意愿行事.
我很困惑这个简单代码(Playground)的错误:
fn main() {
let a = fn1("test123");
}
fn fn1(a1: &str) -> &str {
let a = fn2();
a
}
fn fn2() -> &str {
"12345abc"
}
Run Code Online (Sandbox Code Playgroud)
这些是:
error[E0106]: missing lifetime specifier
--> <anon>:10:13
|
10 | fn fn2() -> &str {
| ^ expected lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
= help: consider giving it a 'static lifetime …
Run Code Online (Sandbox Code Playgroud) scala ×5
postgresql ×2
python ×2
children ×1
elementtree ×1
json ×1
macos ×1
rust ×1
sbt ×1
scala-2.10 ×1
scalac ×1
select ×1
sql ×1
type-erasure ×1
type-members ×1
xml ×1