|
贴个源码
#encoding = utf-8
import pymssql
with pymssql.connect(server="IHHW9EMSYTC2P8V", user="sa", password="123123", database="master", charset="utf8") as conn:
with conn.cursor(as_dict=True) as cursor:
cursor.execute("""
CREATE PROCEDURE FindNum
@号码 VARCHAR(100)
AS BEGIN
SELECT * FROM test WHERE 号码=@号码
END
""")
telnum=input("please input the number you want to put in : ")
cursor.callproc('FindNum', (telnum,))
for row in cursor:
print("姓名=%s, 号码=%s"%(row['姓名'],row['号码']))
conn.close()
这没有缩进我也是醉了,长话短说,利用SELECT 语句查找号码输出中文姓名时出现乱码,因为PYTHON3中sys没有setdefaultencoding()这个函数了,所以网上的方法试过了没用····求解决之道 好人一生平安 |
|