小编Bog*_*dan的帖子

CPU负载和CPU温度的C++代码

我想在Windows中看到CPU临时和CPU负载.我不得不自己编写,而不是像Core Temp这样的软件.我如何访问此信息?

我读了一个与我相似的问题,但没有有用的答案:(.

c++ cpu load

12
推荐指数
1
解决办法
2万
查看次数

从 Python 在页面上执行 JS 代码

我的任务是使用 Python 从任何网页获取命名函数列表。

我有一个使用 JavaScript 编写的脚本。它做我需要的。

当页面加载时,我可以从 JS 控制台(例如从 GoogleChrome 中的开发工具)运行脚本。结果我得到了函数名称的数组。好吧,但我转到页面并手动从浏览器执行脚本。但问题是从 Python 中做同样的事情。它看起来像这样:

def get_named_functions_list(url):
    myscript = settings.get_js_code()  # here I get script that I told above

    tool.open(url)

    while not tool.document.READY: # here I wait while the page will completely loaded
        pass

    js_result = tool.execute_from_console(myscript)

    return list(js_result.values())
Run Code Online (Sandbox Code Playgroud)

那么,Python 中有没有什么工具可以帮助自动解决问题呢?

更新:为了更清楚,我可以将任务划分为子任务列表(在 Python 中):

  1. 请求给定的 url
  2. 等待 document.ready(function...) 将完成。
  3. 执行我的 JS 代码(就像在浏览器中一样)。
  4. 获取 JS 代码返回的结果。

javascript python python-3.x

3
推荐指数
1
解决办法
6418
查看次数

我该怎么做才能将数据/值/对象添加到初始化列表,然后再将其发送到构造函数?

因此,我想练习使用智能指针的技能。我创建了具有以下构造函数的类(单链列表)模板:

template <class Type> 
class list
  {
          //...
   public:
          list( std::initializer_list < Type > initlist ) { ... }

          //...
    };
Run Code Online (Sandbox Code Playgroud)

在主函数中,我想构造初始化器列表并将其作为一件事传递给类构造器(类似这样,我认为这是可能的,但我不知道该怎么做):

typedef int Type;

int main ()
{
   //...
   size_t count; // to know How many elements initlist will have
   std :: initializer_list < Type > initlist;

   cout << "Enter, please, count of elements and their values\n";
   cin >> count;

   Type temp_data;

   for (size_t i = 0; i < count; i++)
     {
        cin >> temp_data; //user input data and …
Run Code Online (Sandbox Code Playgroud)

initialization initializer-list c++11

2
推荐指数
1
解决办法
1478
查看次数