+----+----------+-----------+
| id | gamertag | timestamp |
+----+----------+-----------+
Run Code Online (Sandbox Code Playgroud)
所以我有上面的表格我想只插入一个gamertag,如果它还不存在的话.我怎么能这样做?
$gamertag = "l RaH l";
mysql_query("INSERT INTO `gamertags`(`gamertag`)VALUES ('".$gamertag."')");
Run Code Online (Sandbox Code Playgroud) 我希望这会奏效:
class A:
def __enter__(self, code):
print code
def __exit__(..):
pass
Run Code Online (Sandbox Code Playgroud)
然后:
with A():
f()
g()
Run Code Online (Sandbox Code Playgroud)
会打印:
f()
g()
Run Code Online (Sandbox Code Playgroud)
具体来说,我的目的是获取此代码并从中创建一个函数.所以我可以这样做:with runInThreads()或者with runManyTimesTillSuccess()......
我的目标是将emf,wmf文件格式转换为其他图像文件格式.
我包括image4java jar并尝试将我的emf文件转换为其他格式,如jpg,png ..使用以下代码:
import org.im4java.core.ConvertCmd;
import org.im4java.core.IMOperation;
import java.io.File;
public class im4java {
public static void main(String arg[])
{
File input=new File("src/image.emf");
File output=new File("src/output.jpg");
convertemf2png(input,output);
}
public static void convertemf2png(File input,File output)
{
try{
IMOperation img=new IMOperation();
img.addImage();
img.addImage();
ConvertCmd convert=new ConvertCmd();
convert.run(img,new Object[]{input,output});
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我执行它时,我得到了错误
当我使用时,convert.run(img,new Object[]{input,output});我得到了
java.lang.IllegalArgumentException: java.io.File is an unsupported image-type
at org.im4java.core.ImageCommand.resolveImages(ImageCommand.java:289)
at org.im4java.core.ImageCommand.prepareArguments(ImageCommand.java:189)
at org.im4java.core.ImageCommand.run(ImageCommand.java:208)
at im4java.convertemf2png(im4java.java:27)
at im4java.main(im4java.java:18)
Run Code Online (Sandbox Code Playgroud)当我使用时,`convert.run(img,new Object [] {input.getAbsolutePath(),output.getAbsolutePath()}); 我有, …
#define swap(a,b,c)(int t;t=a;a=b;b=t;);
void main()
{
int x=10,y=20;
swap (x,y,int);
printf("%d %d\n",x,y);
}
Run Code Online (Sandbox Code Playgroud)
什么是输出,为什么?
现在,我将每个xml布局文件存储在res/layout文件夹中,因此管理小项目是可行且简单的,但是当存在大型和重型项目的情况时,则应该存在层次结构和子文件夹布局文件夹.
例如
layout
-- layout_personal
-- personal_detail.xml
-- personal_other.xml
--layout_address
-- address1.xml
-- address2.xml
Run Code Online (Sandbox Code Playgroud)
以同样的方式,我们希望有大型应用程序的子文件夹,所以有没有办法在android项目中这样做?
我可以在布局文件夹中创建layout-personal和layout_address子文件夹,但是当使用R.layout ._______访问xml布局文件的时候,当时内部没有任何xml布局弹出窗口.菜单.
我已经使用wsHTTPBinding配置了WCF服务,但即使这样我也得到了错误
Run Code Online (Sandbox Code Playgroud)Contract requires Session, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it.
这是服务合同定义
<ServiceContract(SessionMode:=SessionMode.Required)>
Public Interface IPrivateService
Run Code Online (Sandbox Code Playgroud)
这是服务实现定义
<ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession)>
Public Class PrivateService
Implements IPrivateService
Run Code Online (Sandbox Code Playgroud)
这是配置设置
<services>
<service behaviorConfiguration="behaviorAction" name="Viking.Service.PrivateService">
<endpoint address="RequiredService" binding="wsHttpBinding" bindingConfiguration="bindingAction" contract="Viking.Service.IPrivateService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="bindingAction" transactionFlow="false" sendTimeout="00:30:00" receiveTimeout="00:30:00">
<reliableSession enabled="true"/>
</binding>
</wsHttpBinding>
</bindings>
Run Code Online (Sandbox Code Playgroud)
真正感谢任何关于这个问题的建议.
我试图使用0.01的步长(例如)从0循环到1.我该怎么做呢?该for i in range(start, stop, step)只需要整数参数,以便花车将无法正常工作.
我试图获取给定对象的所有现有模型字段和属性的列表.是否有一种干净的方式来检查对象,以便我可以获得字段和属性的字典.
class MyModel(Model)
url = models.TextField()
def _get_location(self):
return "%s/jobs/%d"%(url, self.id)
location = property(_get_location)
Run Code Online (Sandbox Code Playgroud)
我想要的是返回一个如下所示的字典:
{
'id' : 1,
'url':'http://foo',
'location' : 'http://foo/jobs/1'
}
Run Code Online (Sandbox Code Playgroud)
我可以model._meta.fields用来获取模型字段,但这不会给我属性但不是真正的DB字段.
如何根据特定条件使相同的按钮执行多个功能并相应地更改按钮上的文本?你如何使用选择器做到这一点?
因此,我希望能够使用GestureOverlayView和OnGestureListener识别高级手势,并且能够使用GestureDetector检测双击和长按.我在两个不同的项目中分别使用这两个功能.但是,我正在尝试将它们结合起来并遇到一些问题.似乎当我尝试双击/长按时,它不被识别,因为GestureOverlayView覆盖整个屏幕并且只能识别手势生成器中定义的高级手势.有谁知道如何设置GestureOverlayView以便它允许GestureDetector完成它的工作?我的代码:
public class HelloAndroid extends Activity implements OnGesturePerformedListener, OnDoubleTapListener, OnGestureListener {
/** Called when the activity is first created. */
private GestureLibrary mLibrary;
private GestureDetector detector;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures);
if (!mLibrary.load()) {
finish();
}
GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures);
gestures.addOnGesturePerformedListener(this);
detector = new GestureDetector(this, this);\
Run Code Online (Sandbox Code Playgroud)
和xml ......
<?xml version="1.0" encoding="utf-8"?>
<android.gesture.GestureOverlayView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gestures"
android:layout_width="fill_parent"
android:visibility="invisible"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
</android.gesture.GestureOverlayView>
Run Code Online (Sandbox Code Playgroud)
提前致谢!