python - 为什么这种格式无效?
问题描述
for skill in skills if skill != "engineering":
...
技能是一个列表,我想在遍历列表时进行检查。
解决方案
这是正确的版本
for skill in skills: # <- with :
if skill != "engineering": # <- with new indention
... # <- with new indention
推荐阅读
- javascript - Object.assign 用于对象数组
- python - 从 Google Drive 中提取文件 - urllib
- android - 如何以编程方式将文本添加到android中的新进度条
- python - python中的文本处理以从字符串中删除十六进制颜色代码
- html - 移动设备和桌面设备上的字体不一样
- node.js - 用于匹配集合中子文档的参考模型字段名称的 Mongodb 聚合管道
- cuda - 每个 SM 的最大驻留块数?
- json - SwiftUI:解码 JSON 数据时出错,其中包括键名称为“iso_3166_1”(字符串 + 数字)
- android - react-native-fs DocumentDirectoryPath 手机上的目录在哪里?
- wordpress - 我想通过产品 ID 以 1 个前端的增量动态更新 menu_order 字段?