试图建立一个基本的乘法表,我不断得到这些"无".他们是什么意思,我怎么能摆脱他们?
>>> def M(n):
... i = 1
... while i <= 6:
... print i*n, '\t',
... i = i +1
... print
>>> def printT():
... w = 1
... while w <= 6:
... print M(w)
... w = w + 1
...
>>> printT()
1 2 3 4 5 6
None
2 4 6 8 10 12
None
3 6 9 12 15 18
None
4 8 12 16 20 24
None
5 10 15 20 …Run Code Online (Sandbox Code Playgroud) 目前我正在尝试应用程序管理的持久化上下文,通过手动创建实体管理器并将它们存储起来以启用跨越JSE应用程序中的多个请求调用(可能类似于扩展持久性上下文)的事务.
但是,我想知道我是否可以通过使用spring的@PersistenceContext注入来避免在整个服务和DAO方法中发送entityManager对象作为附加参数,并使用@Transactional注释标记方法以使用与该实体管理器手动启动的事务.
我想我可以通过使用ThreadLocal来管理这个功能,但我会更高兴能够将它附加到spring框架.
这是我想到的一个例子:
UI动作方法:
在这里我们可以看到事务是由ui逻辑启动的,因为后端没有外观/命令方法将这些调用分组到业务逻辑:
Long transactionid = tool.beginTransaction();
// calling business methods
tool.callBusinessLogic("purchase", "receiveGoods",
paramObject1, transactionid);
tool.callBusinessLogic("inventory", "updateInventory",
paramObject2, transactionid);
tool.commitTransaction(transactionid);
Run Code Online (Sandbox Code Playgroud)
在工具里面:
public Long beginTransaction() {
// create the entity --> for the @PersistentContext
Entitymanager entityManager = createEntityManagerFromFactory();
long id = System.currentTimeMillis();
entityManagerMap.put(id, entitymanager);
// start the transaction --> for the @Transactional ?
entityManager.getTransaction().begin();
return id;
}
public void commitTransaction(Long transactionId) {
EntityManager entityManager = entityManagerMap.get(transactionId);
entityManager.getTransaction().commit();
}
public Object callBusinessLogic(String module, String function,
Object paramObject, Long transactionid) …Run Code Online (Sandbox Code Playgroud) 感谢您的关注,我正在创建一个聊天应用程序.它在很大程度上起作用.我遇到的唯一问题是滚动.我使用EditText从服务器发布新消息.
通过方法
msg = msg + "\n" + newMsg
EditText.setText(msg)
Run Code Online (Sandbox Code Playgroud)
我需要尽快将旧文本下的新文本显示出来.
所以我认为最好的方法是在视图更新后自动向下滚动到底部.
有一个简单的方法吗?喜欢布局吗?
再次感谢!
布局代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/sendButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="send"
/>
<EditText
android:id="@+id/msgBox"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/sendButton"
android:gravity="left"
android:longClickable="false"
/>
<EditText
android:id="@+id/chatBox"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:editable="false"
android:layout_above="@+id/msgBox"
android:scrollbars="vertical"
android:gravity="left|top"
android:isScrollContainer="true"
android:cursorVisible="false"
android:longClickable="false"
android:clickable="false"
android:autoLink="all"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud) UPDATE配置文件SET favourties = CONCAT(favourties,"123")WHERE id = 1
我想在favourties中添加123,但如果favourties的默认值设置为NULL,则此查询将不起作用.如果favourties设置为NULL然后用它附加123,将会查询什么
阅读这个问题,在第一条评论中,@科迪格雷说:
嗯,你知道你不应该重新发布"Debug"版本,对吧?
我很担心.在Visual Studio中,我通常在调试模式下开发我的应用程序,如果我需要分发可执行文件,我所做的就是压缩.exe所需的.dll文件(在bin\Debug文件夹中).
为什么这是个坏主意?
这样做和在发布模式下完全相同的东西有什么区别?
编辑:
我刚才问过这个问题,但我只是想编辑它以增加差异:
当Debug.Assert在代码中使用它来测试它,并在发布模式下编译时,所有这些行都消失了,所以这可能是另一个区别.
我的系统上有几个git存储库,我想在终端列出所有这些存储库.
我正在寻找的是这样的:
/ path/to/my/git/repo/1/REPONAME1
/ path/to/my/git/repo/2/REPONAME2
/ path/to/my/git/repo/3/REPONAME3
如果你能想出如何显示分支名称和回购的状态,例如.[大师] c:0你:1 d:0,那会很棒.
我正在使用RedBean PHP将一些数据从Web scrape转储到数据库中,我需要保留旧ID,最好是作为主键字段.是否可以使用RedBean执行此操作?
当我尝试将id设置为:
$bean->id = 56;
Run Code Online (Sandbox Code Playgroud)
该行未插入 - 最终被创建的查询变为"UPDATE WHERE id= 56",由于该记录尚不存在,因此无效.
我正在使用Canvas.drawText()在自定义视图上写文本.我想在文本后面添加一个背景9-patch drawable,所以我需要知道所绘制文本的边界.文本由用户提供,因此它不是固定大小.
现在我正在使用等宽字体,我设法建立一个看起来不那么糟糕的大小,但在手中我宁愿使用另一种字体.
我们正在将桌面迁移到Windows 7,64位(来自32位Windows XP).我们有许多Winforms C#应用程序,并试图找出在此升级中需要注意的内容.是否有任何建议或良好的资源可以从开发人员的角度来看待需要注意什么才能实现平稳过渡?