在VS环境中怎么调用Python相关函数
发布网友
发布时间:2022-05-01 04:15
我来回答
共1个回答
热心网友
时间:2022-06-24 07:41
我只有一个Python调用VS库的例子,反过来没研究过!应该也有解决方案
import clr
clr.AddReference("System")
clr.AddReference("System.Data")
from System import *
from System.Data import *
from System.Data.SqlClient import SqlCommand, SqlConnection
from System.Diagnostics import *
def testDb():
conn = SqlConnection()
conn.ConnectionString = "User ID=sa;password=sa;Initial Catalog=staff;Data Source=."
conn.Open()
sql = "select top 10 * from tbtype"
cmd = SqlCommand(sql, conn)
reader = cmd.ExecuteReader()
lst =[]
while reader.Read():
fdclass = reader["fdclass"]
fdclassName = reader["fdclassname"]
lst.append('%s=%s'%(fdclass,fdclassName))
reader.Close()
cmd.Dispose()
conn.Close()