Discuss / Python / 源码中不知道用途

源码中不知道用途

Topic source

def create_args_string(num): L = [] for n in range(num): L.append('?') return ', '.join(L)

这部分是干什么的 以及最后‘,’.join(L)是什么意思 求解答

灰_手

#2 Created at ... [Delete] [Delete and Lock User]

这个函数主要是生成一个'?, ?, ?, ?'的SQL语句的参数,可以用', '.join('?' * len(mappings)来代替,其他SQL语言简化可以参考orm.py

attrs['__insert__'] = 'insert into `%s` (%s) values (%s)' % (table, ', '.join('`%s`' % f for f in mappings), ', '.join('?' * len(mappings)))

谢啦

灰_手

#4 Created at ... [Delete] [Delete and Lock User]

刚写了注释,欢迎指教。


  • 1

Reply