我是靠谱客的博主 难过项链,这篇文章主要介绍python中多重if语句用法_Python3 |在for循环中使用多个if语句?,现在分享给大家,希望可以做个参考。

我找遍了,没有找到符合我需要的东西。在

我有三个for循环,每个循环中都有一个if条件。代码如下:for friend in friends:

columns = friend.split("n")

if len(columns) == 4:

c.execute("""INSERT INTO `fb_friends`(`name`, `no_of_mutual_friends`, `no_of_new_posts`, `already_friends`) VALUES (?, ?, ?, ?)""", (columns))

for friend in friends:

columns = friend.split("n")

if len(columns) == 3:

c.execute("""INSERT INTO `fb_friends`(`name`, `no_of_mutual_friends`, `already_friends`) VALUES (?, ?, ?)""", (columns))

for friend in friends:

columns = friend.split("n")

if len(columns) == 2:

c.execute("""INSERT INTO `fb_friends`(`name`, `no_of_mutual_friends`, `already_friends`) VALUES (?, ?, ?)""", (columns))

有没有更有效的方法?我在想and运算符是这样的:

^{pr2}$

有谁能提出最好或最有效的方法来完成这项工作,比如在同一个列表上迭代三次?在

最后

以上就是难过项链最近收集整理的关于python中多重if语句用法_Python3 |在for循环中使用多个if语句?的全部内容,更多相关python中多重if语句用法_Python3内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(116)

评论列表共有 0 条评论

立即
投稿
返回
顶部