>>> D = {'a': 1, 'b': 2, 'c': 3}
>>> D
{'a': 1, 'c': 3, 'b': 2}
Run Code Online (Sandbox Code Playgroud)
我只是在Python shell中做了这个,我只是想知道为什么键'c'会在键'b'之后?
我想在 GORM 中表达以下表格:
CREATE TABLE indexes (
id INTEGER PRIMARY KEY,
name VARCHAR
)
CREATE TABLE services (
id INTEGER PRIMARY KEY,
name VARCHAR
)
CREATE TABLE index_service (
index_id INTEGER REFERENCES indexes(id),
service_id INTEGER REFERENCES services(id),
write_active INTEGER,
PRIMARY KEY (index_id, service_id)
)
Run Code Online (Sandbox Code Playgroud)
阅读有关堆栈溢出的文档和问题后。我仍然找不到关于如何在 GORM 的 DSL 中表达附加列 write_active 的答案
到目前为止我得到的是
type Index struct {
ID unit `json:"id" gorm:"primary_key"`
Name string `json:"name" gorm:"not null"`
}
type Service struct {
ID unit `json:"id" gorm:"primary_key"`
Name string `json:"name" gorm:"not null"`
} …Run Code Online (Sandbox Code Playgroud) 我正在做一个15拼图(http://en.wikipedia.org/wiki/Fifteen_puzzle)游戏,我有一个活动供用户选择背景图像,然后我将该图像传递给一个新的活动,以便缩放并裁剪它.
现在我想首先向用户显示解决方案3秒然后它会随机播放,我使用的代码如下:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//...skip the code that gets the image and scales it
start();
}
Run Code Online (Sandbox Code Playgroud)
然后在我的start()函数中:
public void start() {
//the createPuzzle function would create all the Views(tiles)
//and add them to the root LinearLayout using addView() function
createPuzzle(game.getBoardConfig(), dimension);
//i was trying to sleep here
shuffle();
}
Run Code Online (Sandbox Code Playgroud)
我用了:
try {
Thread.sleep(3000);
} catch (InterruptedException e) {}
Run Code Online (Sandbox Code Playgroud)
要么:
SystemClock.sleep(3000);
Run Code Online (Sandbox Code Playgroud)
但是他们都没有正常工作,他们在我选择图像后立即暂停了线程,当它暂停时我看不到新活动和我创建的图块.当线程恢复时,它已经显示了混乱的拼图.
我一直在查看文档很长一段时间,但仍然无法弄清楚我的代码有什么问题,谢谢你的帮助!