调用一个控制台程序,获取它的标准输出,或把它的标准输出重定向到界面上,这里只介绍如何获取它的标准输出,因为原理都一样的。
使用python2.5的subprocess模块来实现。
import sys
import subprocess
def RunShellWithReturnCode(command, print_output=False,
universal_newlines=True):
"""Executes a command and returns the output from stdout and the return code.
Args:
command: Command to execute.
print_output: If True, the output is printed to stdout.
If False, both stdout and stderr are ignored.
universal_newlines: Use universal_newlines flag (default: True).
Returns:
Tuple (output, return code)
"""
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
shell=use_shell, universal_newlines=universal_newlines)
if print_output:
output_array = []
while True:
line = p.stdout.readline()
if not line:
break ......
PLY模块 是Lex/YACCPython 的实现,可以用来实现词法分析/语法分析,但如何用,还没研究,以后有时间再研究吧;
主页: http://www.dabeaz.com/ply/
pycparser模块 是使用PLY模块分析c语言语法的模块,没什么文档,但模块自带了例子和测试用例。
主页: http://code.google.com/p/pycparser/ ......
软件准备:
1.eclipse开发包,下载地址:http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/galileo/SR2/eclipse-java-galileo-SR2-win32.zip
2.pydev插件,下载地址:http://sourceforge.net/projects/pydev/files/pydev/Pydev%201.5.4/org.python.pydev.feature-1.5.4.2010011921.zip/download
eclispe3.4和3.5搭建过程:
安装eclipse
因为eclipse是绿色软件,不需要安装,将eclipse的安装包解压缩后就可直接使用。
安装pydev插件
将下载的pydev插件解压缩,选择"解压到org.python.pydev.feature-1.5.4.2010011921"选项。将解压缩得到的文件夹发到eclispe文件夹中的dropins目录里面。
设置pydev
1.双击"eclispe.exe"打开eclipse;
2.点击:"window->Preference",打开Preference对话框;
3.在preference中选择左树中的"Pydev->Interpreter";
4.单击右边的"New..."按钮,弹出"select interpreter"对话框;
5.在 "select interpreter"对话框中,点击"Browse...";
6.在弹出的文件打开对话框中,选择已安装的python解释器(python.exe),点击"打开";
7.在"select interpreters" 中,点击"ok";
8.在弹出的"Selectin N ......
有三种办法
第一种是用access的JDBC驱动程序,到http://industry.java.sun.com/products/jdbc/drivers这个网站上查找并下在access的jdbc驱动程序。
第二个办法是你用下面的代码试试
con = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/data/Access/test1.mdb","dba","sql");
后面的代码一样。这样你就可以访问access数据库了。
第三个是用sun的jdbcodbc桥,这个大家用的多了,在此就不写了
例子一、
/*
用JDBC来连接数据库有很两种方式,如
<1>JDBC:ODBC bridge,
<2>直接连接方式.
第二种方式有很多好处,它可以独立于依赖于系统的odbc数据源,
存储数据的database可以自由地移动
  ......
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
/// <summary>
/// DB 的摘要描述
/// </summary>
public class DB
{
OleDbConnection conn = null;
OleDbCommand cmd = new OleDbCommand();
public DB()
{
//
// TODO: 在此加入建構函式的程式碼
//
string dbname = System.Web.HttpContext.Current.Server.MapPath("DB_App/netData.aspx");
string conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+dbname;
conn = new OleDbConnection(conStr);
}
public OleDbConnection getConn()
{
&nbs ......
MS Access语法错误信息
This short article deals with the following common MS Access-related error messages:
Syntax error (missing operator) in query expression 'field='some_partial_string'
Syntax error in INSERT INTO statement
Syntax error in UPDATE statement
Syntax error in from clause
Syntax error in WHERE clause
There are 4 main causes for these errors: using a Reserved Word for a field name; embedded spaces in field or table names; attempting to insert unescaped single quotes; and incorrectly delimited datatypes. There is a fifth cause, and that is a genuine syntax error resulting from a typo, or otherwise misconstructed SQL statement. Assuming that you are sure this fifth cause is not applicable in your case, here's how to deal with the other four.
Reserved Words and Embedded Spaces
The most common culprits among reserved words are NAME and PASSWORD, which at first glance appear to be perfectly reasonable choices for field names in, say, a User table. What can be mor ......