我正在尝试使用python的requests
模块从Web下载并保存图像.
这是我使用的(工作)代码:
img = urllib2.urlopen(settings.STATICMAP_URL.format(**data))
with open(path, 'w') as f:
f.write(img.read())
Run Code Online (Sandbox Code Playgroud)
以下是使用以下内容的新(非工作)代码requests
:
r = requests.get(settings.STATICMAP_URL.format(**data))
if r.status_code == 200:
img = r.raw.read()
with open(path, 'w') as f:
f.write(img)
Run Code Online (Sandbox Code Playgroud)
你能帮助我从响应中使用什么属性requests
吗?
希望有人可以帮助我 - 我想替换字符串中的某个字符,我想知道最好的方法是什么?
我知道角色的位置,例如,如果我想将字符串中的第3个字符从A更改为B - 我将如何编码?
我注意到android.media.effect
开发人员可以在api级别17中使用.还有一个示例'Helloeffect'供开发人员渲染.但是,样本专注于图片.我读了效果类的文件,发现它必须对GL
纹理应用效果.我是新手opengl
,我想对相机拍摄的视频帧应用效果.
任何人都可以给我一些提示吗?谢谢!
我现在正在将Gradle用于我的所有项目,甚至用于javadoc生成.
android.libraryVariants.all { variant ->
task("generate${variant.name}Javadoc", type: Javadoc) {
title = "$name $version API"
source = variant.javaCompile.source
ext.androidJar = "${android.plugin.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
ext.googlePlayServicesJar = "${android.plugin.sdkDirectory}/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar"
classpath = files(variant.javaCompile.classpath.files, ext.androidJar, ext.googlePlayServicesJar)
options.links("http://docs.oracle.com/javase/7/docs/api/");
options.links("http://d.android.com/reference/");
//options.linksOffline("http://d.android.com/reference", "${android.plugin.sdkDirectory}/docs/reference");
exclude '**/BuildConfig.java'
exclude '**/R.java'
}
}
Run Code Online (Sandbox Code Playgroud)
使用该代码,我得到了一切工作,除了一件事:常规的Android API对象,如Activity,Bitmap等.Java的链接工作正常.
最终生成的文档未链接到http://d.android.com/reference.我尝试了两个options.links()options.linksOffline()
但没有成功.
编辑
感谢@ejb,问题在于您无法同时提供多个options.links()
.所以我使用了options.links()
Java的文档和options.linksOffline()
Android的文档:
options {
links("http://docs.oracle.com/javase/7/docs/api/");
linksOffline("http://d.android.com/reference", "${android.plugin.sdkDirectory}/docs/reference");
//stylesheetFile = new File(projectDir, "stylesheet.css");
}
Run Code Online (Sandbox Code Playgroud) 我有一个Nginx vhost而不是这样配置:
...
location /one {
include uwsgi_params;
uwsgi_pass unix:///.../one.sock;
}
location /two {
include uwsgi_params;
uwsgi_pass unix:///.../two.sock
}
...
Run Code Online (Sandbox Code Playgroud)
这当然是简化的配置
当我请求/one/something
我希望我的Python脚本接收/something
为request_uri
.
我正在使用BottlePy,但希望由Nginx处理,而不是在我的Python代码中处理.
我能做点什么uwsgi_param REQUEST_URI replace($request_uri, '^/one', '')
吗?
编辑
以下是我的Python代码的请求:[pid:30052 | app:0 | req:1/1](){42 vars in 844 bytes} [Tue Aug 21 14:22:07 2012] GET/one/something = >在4 msecs(HTTP/1.1 200)中生成0个字节,在85个字节中生成2个标头(核心0上的0个开关)
所以Python是可以的,但uWSGI不是.
如何解决?
这个错误只发生在我的Nexus 5和运行Lollipop的 Nexus 7上.
编辑
当我进入收件箱>设置>通知>任何项目并返回时,Google的新收件箱应用中也会出现此错误...
/编辑
我有一个GalleryActivity
显示多个图像,每页一次(在a ViewPager
.当我点击后退按钮时,有时Android的SystemUI有毛刺.
普通视图
Glitched视图
看看这些观点如何重复,并在系统内部重演?
简单的触摸事件会恢复正常的SystemUI视图.
到底是怎么回事?
可能类似于:
我正试图pysqlite
从我的系统中删除pip
.
我这样做是没有意义的:
$ pip uninstall pysqlite
Run Code Online (Sandbox Code Playgroud)
该命令有效,但请注意:
$ pip freeze
[...]
pysqlite==1.0.1
Run Code Online (Sandbox Code Playgroud)
让我们再试一次
$ pip uninstall pysqlite
Can't uninstall 'pysqlite'. No files were found to uninstall.
Run Code Online (Sandbox Code Playgroud)
诺普,似乎被删除但仍然出现 pip freeze
现在来了很有趣
$ pip install pysqlite
Requirement already satisfied (use --upgrade to upgrade): pysqlite in /usr/lib/python2.6/dist-packages
Cleaning up...
Run Code Online (Sandbox Code Playgroud)
很公平:
$ pip install -U pysqlite
[...]
error: command 'gcc' failed with exit status 1
[...]
Can't roll back pysqlite; was not uninstalled
[...]
Run Code Online (Sandbox Code Playgroud)
我只是不明白.为什么不能pip卸载pysqlite?
切换到Android棉花糖API,我使用org.apache.http.conn.util.InetAddressUtils
了InetAddressUtils.isIPv4Address(ipAddress)
一个代码,列出从设备的所有IP.
作为API-23更改的一部分,该InetAddressUtils
课程现已消失.
我现在如何替换以下代码?
public static String ipAddress() {
try {
for (final Enumeration<NetworkInterface> enumerationNetworkInterface = NetworkInterface.getNetworkInterfaces(); enumerationNetworkInterface.hasMoreElements();) {
final NetworkInterface networkInterface = enumerationNetworkInterface.nextElement();
for (Enumeration<InetAddress> enumerationInetAddress = networkInterface.getInetAddresses(); enumerationInetAddress.hasMoreElements();) {
final InetAddress inetAddress = enumerationInetAddress.nextElement();
final String ipAddress = inetAddress.getHostAddress();
if (! inetAddress.isLoopbackAddress() && InetAddressUtils.isIPv4Address(ipAddress)) {
return ipAddress;
}
}
}
return null;
}
catch (final Exception e) {
LogHelper.wtf(null, e);
return null;
}
}
Run Code Online (Sandbox Code Playgroud) 当我运行应用程序时,它安装但随后崩溃,ecplise不告诉我的代码有任何问题.我认为这是我的清单的一个问题...
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.secondapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.example.secondapp" />
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
你们看到有什么问题吗?
10-19 10:41:25.589: E/AndroidRuntime(10147): FATAL EXCEPTION: main
10-19 10:41:25.589: E/AndroidRuntime(10147): java.lang.NoSuchMethodError: com.example.secondapp.MainActivity.getActionBar
10-19 10:41:25.589: E/AndroidRuntime(10147): at com.example.secondapp.MainActivity.onCreate(MainActivity.java:15)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
10-19 10:41:25.589: E/AndroidRuntime(10147): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
10-19 10:41:25.589: E/AndroidRuntime(10147): …
Run Code Online (Sandbox Code Playgroud) 这段代码工作正常.
我想要的唯一改进是 - 当我传递"Pi"时,它会获取以名称"Pi"开头的所有项目对象,但是当我输入"pi"时它什么都不返回!
这意味着我希望这种方法startAt(itemName)
不区分大小写.所以这应该适用于任何事情(小写或大写),在这种情况下"Pi"或"pi"等.
//5. Get menu items from RestaurantMenu
this.getMenuItemFromRestaurantMenu = function(callback, itemName) {
var ref_restMenu = firebase.database().ref()
.child('Restaurants')
.child('Company')
.child('menu');
//Check if item is already exist!
ref_restMenu.orderByChild("itemName").startAt(itemName).once("value", function(snapshot) {
var data = snapshot.val();
if(data !== null) {
//We will ger item name and restaurant id from this data.
callback(data);
} else {
//Item not found in globalMenu
console.log("%c Item not found in Global Menu", "color: red");
}
});
}
Run Code Online (Sandbox Code Playgroud)