我正在做一个3D骰子,当你刷它的脸时旋转.问题是它在某些情况下表现得非常奇怪.例如,如果您运行代码段并向左滑动两次然后向下滑动,则会进行疯狂的旋转...
这是代码:
$(function() {
var X = 0,
Y = 0;
var hammertime = new Hammer($(".thirdDimension")[0], {domEvents: true});
hammertime.get('swipe').set({ direction: Hammer.DIRECTION_ALL });
function rotate(what) {
switch (what) {
case "X":
$(".cube").css("transform", "rotateX(" + X + "deg) rotateY(" + Y +"deg)");
break;
case "Y":
$(".cube").css("transform", "rotateY(" + Y +"deg) rotateX(" + X + "deg)");
break;
}
$("#debug").html($("#debug").html() + $(".cube").attr("style") + "<br>").scrollTop($("#debug")[0].scrollHeight);
}
$(".thirdDimension").on("swipeleft", function(e){
Y -= 90;
rotate("Y");
});
$(".thirdDimension").on("swiperight", function(e){
Y += 90;
rotate("Y");
});
$(".thirdDimension").on("swipeup", function(e){
X += 90; …Run Code Online (Sandbox Code Playgroud)在python 2.7中我能够做到:
file('text.txt', 'w').write('some text')
Run Code Online (Sandbox Code Playgroud)
但是在python 3中我必须使用open函数,所以我不能再写一行文件了.
f = open('text.txt', 'w')
print('some text', file = f)
f.close()
Run Code Online (Sandbox Code Playgroud)
他们为什么删除这个file功能?
我正在尝试这段代码,期望它在反转后返回一个文本字符串,[::-1]但它不起作用.
class meh:
def __init__(self, bla):
self.bla = bla
def __reversed__(self):
return "Reversing!!!! %s" % self.bla[::-1]
a = meh("Reversed successfully!!!!")
print a[::-1]
Run Code Online (Sandbox Code Playgroud)
如何正确调用该__reverse__功能?示例:__gt__调用a > 25,调用__reverse__什么?
为什么这段代码不返回预期的连接字符串,而是2?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const char * meh() {
char meh1[32] = "This ";
char meh2[32] = "should work :)";
return strcat(meh1, meh2);
}
int main() {
printf(meh());
return 0;
}
Run Code Online (Sandbox Code Playgroud) python ×2
c ×1
class ×1
css3 ×1
deprecated ×1
file ×1
function ×1
html ×1
javascript ×1
jquery ×1
python-2.7 ×1
python-3.x ×1
reverse ×1
strcat ×1