pyautogui.dragTo(100, 200, button='left') # drag mouse to (100, 200) while holding down left mouse button pyautogui.dragTo(300, 400, 2, button='left') # drag mouse to (300, 400) over 2 seconds while holding down left mouse button pyautogui.drag(30, 0, 2, button='right') # drag the mouse left 30 pixels over 2 seconds while holding down the right mouse button
Java: ant: NO JNI: /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include/linux /usr/lib/jvm/default-java/include Java wrappers: NO Java tests: NO
Install to: /usr/local -----------------------------------------------------------------
// 下面這樣的寫法也可以,但會有一些副作用,記憶體配置上不連續,以及分開記憶體配置效能相對低弱 // Note: Using new expression as constructor argument // creates no named variable for other code to access. shared_ptr<Song> sp2(new Song("Lady Gaga", "Poker Face"));
// When initialization must be separate from declaration, e.g. class members, // initialize with nullptr to make your programming intent explicit. shared_ptr<Song> sp5(nullptr); //等於: shared_ptr<Song> sp5; sp5 = make_shared<Song>("Avril Lavigne", "What The Hell");
在 Scott Meyers 大神的《Effective Modern C++》書裡的條款 21 也提到:「盡量用 std::make_shared 取代直接使用 new」
voidSmartPointerDemo2(){ // Create the object and pass it to a smart pointer std::shared_ptr<LargeObject> pLarge(new LargeObject());
// Call a method on the object pLarge->DoSomething();
// 在離開函式前手動釋放記憶體 pLarge.reset();
// ...
}
重複釋放記憶體問題
不建議使用下列這種寫法,用原始指標變數(下例中的p)去建立 shared_ptr 這種寫法容易造成重複釋放記憶體問題,因為 new Object 完後有個原始指標變數 p 指向這個物件,容易造成其它地方再把 p 建立 shared_ptr, 之後 sp 釋放完該物件後(delete),sp2 又再次釋放完該物件,造成重複釋放記憶體,