python-2.7 - 无效的语法python 2.7
问题描述
在 Visual Studio 2019 IDE 中以及在 IDE 外运行 .py 文件时,else 语句一直标记为无效语法。我一直看到 else 的无效令牌:但是通过 python 文档查看这似乎是正确的。我正在构建一个系统重启脚本来推动 MDM 解决方案。这只是脚本的非常基本的开始。
import os
import time
import datetime
WorkStatus = input ("We are going to restart this computer now, did you save your work? Y or N")
if workStatus == n: print ('Save your work now restart will occur in 5 minutes')
# wait 5 minutes
print ("rebooting in 5 minutes")
time.sleep(300)
else:
os.system ("Shutdown /r /t 10")
解决方案
import os
import time
import datetime
WorkStatus = input ("We are going to restart this computer now, did you save your work? Y or N")
if workStatus == n:
print ('Save your work now restart will occur in 5 minutes')
# wait 5 minutes
print ("rebooting in 5 minutes")
time.sleep(300)
else:
os.system ("Shutdown /r /t 10")
推荐阅读
- r - 找出 2 个表 (`tbl_spark`) 是否相等而不使用 sparklyr 收集它们
- tomcat - tomcat 未显示在 intelliJ 的运行/调试工具栏上
- azure-active-directory - 为什么 Azure AD 不支持默认域进行登录
- oracle - 如何将 csv 数据插入到 oracle 表中?
- android - 在firebase android中注册OTP电话身份验证时如何查找用户是否已经存在?
- tensorflow - 如何训练 tensorflow 对象检测模型避免在电视上检测到人?
- postgresql - Docker无法连接到管理员端口
- c# - 正则表达式用多个单词中的相同值替换字符串
- javascript - 选中一个带有动态值的单选按钮
- vert.x - Vert.x 事件总线关闭