我可以创建专辑,使用requests和oauth-hook模块就好了,但我似乎无法获得一个名称。在此处查看文档:http : //api.imgur.com/resources_auth#account_albums。我使用的是 Windows7x64 Python2.7,requests版本 0.21.1 和oauth-hook版本 0.4.0
奇怪的是,当我上传图像时使用相同的方法命名图像,脚本工作得很好。这是相关的代码:
client = requests.session(hooks={'pre_request': authorizedHook})
url = r'http://api.imgur.com/2/account/albums.json'
parameters = {'title': 'ALBUMTITLEHERE'}
r = client.post(url, data=parameters)
Run Code Online (Sandbox Code Playgroud)
一旦我将它加载到json:
Created Album data:
{u'albums': {u'anonymous_link': u'http://imgur.com/a/i3Gal',
u'cover': u'',
u'datetime': u'2012-05-24 02:34:42',
u'description': u'',
u'id': u'i3Gal',
u'layout': u'blog',
u'link': u'http://tankorsmash.imgur.com/1B498',
u'order': 0,
u'privacy': u'public',
u'title': u''}}
Run Code Online (Sandbox Code Playgroud)
我期待的是一个名为ALBUMTITLEHERE. 而是创建了一个未命名的。我究竟做错了什么?
无关:Stats API 似乎根本没有为我返回任何东西,但我不确定这是否相关。
我正在避免使用任何其他模块.
我想要做的是使用pywin32 libary在Excel中设置单元格的颜色.到目前为止,我已经找到了如何让细胞变色:
print xl.ActiveSheet.Cells(row, column).interior.color
Run Code Online (Sandbox Code Playgroud)
你可以通过以类似的方式分配它来设置它:
xl.ActiveSheet.Cells(row, column).interior.color = 0 #black
Run Code Online (Sandbox Code Playgroud)
我的问题是如何设置RGB的单元格颜色?
我需要一个叫做ColorTranslator到OLE的东西,但我不知道如何访问,system.drawing因为它似乎是一.NET件事.http://msdn.microsoft.com/en-us/library/system.drawing.colortranslator.toole.aspx
a是一个numpy数组,a.T它是转置.一旦我添加a和a.Tas a += a.T,答案是不期望的.谁能告诉我为什么?谢谢.
import numpy
a = numpy.ones((100, 100))
a += a.T
a
array([[ 2., 2., 2., ..., 2., 2., 2.],
[ 2., 2., 2., ..., 2., 2., 2.],
[ 2., 2., 2., ..., 2., 2., 2.],
...,
[ 3., 3., 3., ..., 2., 2., 2.],
[ 3., 3., 3., ..., 2., 2., 2.],
[ 3., 3., 3., ..., 2., 2., 2.]])
Run Code Online (Sandbox Code Playgroud) 我有一个矩阵:
[[1 2 3],
[4 5 6],
[7 8 9]]
Run Code Online (Sandbox Code Playgroud)
我需要创建一个新矩阵:
[[7 4 1],
[8 5 2],
[9 6 3]]
Run Code Online (Sandbox Code Playgroud)
我试过了
new_matrix = [[1]]
new_matrix.append(matrix[1][0])
Run Code Online (Sandbox Code Playgroud)
得到一个new_matrix = [4 1]而不是new_matrix =[1 4]
如果您需要更多说明,请询问.
我的问题是我试图将两个不同的RenderTarget2D绘制到屏幕上,但只显示最后绘制的一个.代码类似于以下代码,并且需要使用该Draw方法绘制的类的每个实例一次调用两次:
public override void Draw()
{
gfxDevice.SetRenderTarget(myRenderTarget);
gfxDevice.Clear(Thistle);
//pseudocode
foreach (something in a list)
{ spritebatch.begin();
spritebatch.DrawString(something);
spritebatch.end();
}
//reset to the backbuffer
gfxDevice.SetRenderTarget(null);
gfxDevice.Clear(backgroundColor) //Here is what I thought the offending line was
//draw the RenderTarget to backbuffer
spriteBatch.Begin();
spriteBatch.Draw(myRenderTarget, rect, this.backgroundColor);
spriteBatch.End();
Run Code Online (Sandbox Code Playgroud)
我认为解决方案是graphicsDevice每次Draw()调用方法时停止清除,但如果不这样做,除了新绘制的rendertarget之外的所有内容都会被绘制成一个丑陋的紫色.像这样:
End()由于这个问题,我想,紫色来自spritebatch
我需要更改什么才能正确绘制RenderTargets,这意味着两个小部件都会被绘制,以及正确的Color.Thistle背景?
理想情况下,屏幕看起来像两者的组合:
和 
在Python中,我可以做一些这样的事情,我认为这比一个语句中的两对条件更清晰:
if 1 < 2 < 3:
print 'triple testing?'
else:
print 'more like triple failing!'
Run Code Online (Sandbox Code Playgroud)
没有遇到任何问题,但是在C#中,它将第一次比较1 < 2转换为bool之前的转换,因此它会引发异常Operator '<' cannot be applied to operands of type 'bool' and 'int'.
有没有办法避免添加第二个条件,所以我不必将三重条件分成两组,而不是一个"三重"条件,就像我在Python中可以做到的那样?
if (1 < 2 & 2 < 3) { ... }
Run Code Online (Sandbox Code Playgroud)
编辑:我使用它的一个例子是确保inta在一系列数字之间.
if ((0 < x) && (x < 10) { ... } //I can already do this
vs
if (0 < x < 10) { ... } //Would …Run Code Online (Sandbox Code Playgroud) 我正在使用cocos2d v2.0.0和模拟器6.1.
当我在xcode中的iPhone5模拟器中编译项目时,表面大小是
cocos2d:表面尺寸:1136x640
该应用程序正常工作,适合屏幕边框1136x640,但当我在iPhone5设备上运行应用程序,我得到
cocos2d:表面尺寸:960x640
图像不再覆盖整个屏幕.
问题是什么?
jQuery 中是否有与 C# 类似的功能Session["Param"]?我该如何使用它?
我在 jQuery 中搜索过"sessionStorage",但我无法理解。