python 中 sql 带参数

使用 python 的字符串填充方式 import mysql.connector sql = ‘select \* from school.student where age > {age} and address = {addr};’ info = {‘age’ : 18, ‘addr’ : ‘shenzhen’} # 参数是字典类型 sql = sql.format(\*\*info) mysql\_conn = mysql.connector.connect(host=’host’, user=’user’, passwd=’password’) cursor = conn.cursor() cursor.execute(sql) 使用 sql 模块中自带的填充方式 import mysql.connector sql = ‘select \* from school.student where age > […]

python 格式字符串中的填充符

使用 %类型 来填充 常用的有: %s 填充字符串类型; %d 填充 int 类型; 这里是沿用了 C语言中 printf() 函数中的格式,更多的信息请查看:完整列表 name = ‘tommy’ message = ‘hello %s’ % name print(message) 结果是:hello tommy 同时填充多个时,需要使用元组 name = ‘tommy’ age = 29 message = ‘my name is %s, i am %d years old.’ % (name, age) print(message) 结果是:my name is tommy, i am 29 […]

解决 vs2017 打断点无效

打断点无效 断点显示白色,鼠标移上去,提示:The breakpoint will not currently be hit. No Symbols have been loaded for this document. 如下图: 解决方法 Debug > Options > General > 将 “Enable Just My Code”前的复选框取消掉