所以我是Python的新手,到目前为止我只制作了JS和PHP。
所以我有这个代码
"""Shutdown code"""
#timeToShutdown = input("Time to shutdown: ")
import os
os.system("shutdown /s /t 7200")
它不起作用(不做任何事),
它只能像这样工作
int(input())
那么输入数字作为变量有什么问题。
PS:我也试过class Base
{
public:
virtual ~Base() { }
protected:
virtual void update_internal() = 0;
};
class Node_A : public Base
{
protected:
virtual void update_internal() { std::cout << "Update Node A" << std::endl; }
};
class Node_B : public Base
{
protected:
virtual void update_internal() { std::cout << "Update Node B" << std::endl; }
};
class Root : public Base
{
public:
void add_node (Base* node) { m_nodes.push_back(node); }
void update()
{
for (auto& node : m_nodes)
{
node->update_internal();
}
}
protected:
std::vector<Base*> m_nodes;
virtual void update_internal() { }
};
int main()
{
Node_A alpha_node;
Node_B beta_node;
Root root_node;
root_node.add_node(&alpha_node);
root_node.add_node(&beta_node);
root_node.update();
}
。
答案 0 :(得分:3)
您必须格式化字符串,而不是返回。即,将%
移到括号内:
os.system("shutdown /s /t %s" % timeToShutdown)
^ input() returns a string not a number