我是一个全新的人,Terminal中的所有东西都超出了我。
我想在计算机上安装Pillow 5.3,但是它进入了Library中的Python 2.7文件夹。据我了解,我一直在PyCharm中使用Python 3.7。
所有导入命令均不起作用:
import PIL
from PIL import pillow
import pillow
Run Code Online (Sandbox Code Playgroud)
我的系统无法识别任何这些。我是否需要将Pillow 5.3文件夹移到某处?我一定在某处错过了一步。
我正在练习 javascript,并创建了一个带有两个骰子和数字 1-12 的小骰子掷骰子。骰子被掷出,与骰子掷出总数相匹配的数字(1-12)会出现红色虚线边框,当您单击它时,它会变成灰色。
我的图像源是“die_1”到“die_6”,我只是随机生成一个数字1-6,然后将其放入“die_”字符串中以更改图像的src。
现在,如果您滚动的数字已经是灰色的,我会弹出一个警报,显示“再次滚动”。
我的问题是:在我当前的实现中,在骰子图像更改之前会弹出警报。一旦我单击“确定”,骰子就会更改以显示滚动的数字。有没有办法延迟警报,直到骰子的图像发生变化?
var diePicture1 = document.getElementById("die1");
var diePicture2 = document.getElementById("die2");
const NUMBERBUTTONS = document.querySelectorAll(".number-button");
buttonRoll = document.getElementById('roll');
/* Gets the values of the dice and adds them */
function totalDice(){
var die1Value = parseInt(diePicture1.src.substring(diePicture1.src.length - 5,diePicture1.src.length-4));
var die2Value = parseInt(diePicture2.src.substring(diePicture2.src.length - 5,diePicture1.src.length-4));
var result = die1Value + die2Value;
return result;
}
buttonRoll.addEventListener('click', function(){
/*Randomly generates two numbers 1-6
then changes the img src to match */
var dieNumber1 = Math.floor(Math.random()*6) +1;
var dieNumber2 = Math.floor(Math.random()*6) …Run Code Online (Sandbox Code Playgroud) 我有一个对象,其中一个数组(类对象)作为其值之一。我有一个函数,部分地在该数组内(对象内)的对象之一上运行类方法。
当我运行代码时,在函数之前和之后打印数组,更改在函数运行之前和之后都存在。
为什么会发生这种情况?吊装?
作为测试,我在对象中创建了另一个键:值对,使得该值是一个整数,并将我的函数更改为将该整数增加 1。在这里,它工作正常 - 在函数之前打印我的对象整数为1,然后整数为2。
我也尝试不使用对象上的类方法来进行调整,但仍然失败。
class Book{
constructor (color, title, pagecount){
this.color = color;
this.title = title;
this.pagecount = pagecount;
}
changePages() {
this.pagecount += 50;
}
}
let book1 = new Book("Red", "Book1", 100);
let book2 = new Book("Blue", "Book2", 200);
let book3 = new Book("Green", "Book3", 300);
var myBookArr = [book1, book2, book3]
var myObj = {arr: myBookArr, integerTest: 0}
function thisDoesStuff(){
//other operations not related to myObj
myObj.arr[0].changePages();
}
Run Code Online (Sandbox Code Playgroud)
当我在两个 console.logs 中运行以下命令时,它显示 arr[0] (即 …