我在服务器上运行了Django脚本,为发送到服务器的每个请求创建会话变量.该脚本根据先前存储的会话变量返回特定值.
当我在浏览器上测试脚本时,Django上的会话按照要求工作.
但是,在使用Volley发送相同请求时,脚本会将每个请求视为新请求,而不考虑先前的会话变量.
StringRequest stringRequest = new StringRequest(Request.Method.GET,Send_URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Response(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
requestQueue.add(stringRequest);
}
Run Code Online (Sandbox Code Playgroud)
RequestQueue defined globally and context assigned in the onCreate() method
PS我通过浏览器请求重新检查它的工作原理.所以Django End没有问题.
谢谢!
我正在编写一个记录 wav 文件的应用程序。wav 文件中的间隙(静音)将被阈值删除。因为这通常会导致最后一个音符和下一个音符之间出现贯穿。当演讲者长时间停顿时,如何在中间添加持续的沉默?
bufferSize = AudioRecord.getMinBufferSize(frequency,
channelConfiguration, audioEncoding);
AudioRecord audioRecord = new AudioRecord( MediaRecorder.AudioSource.MIC, frequency,
channelConfiguration, audioEncoding, bufferSize);
short[] buffer = new short[bufferSize];
audioRecord.startRecording();
while (started) {
int bufferReadResult = audioRecord.read(buffer, 0,bufferSize);
if(AudioRecord.ERROR_INVALID_OPERATION != bufferReadResult){
//check signal
//put a threshold
int foundPeak=searchThreshold(buffer,threshold);
if (foundPeak>-1){ //found signal
//record signal
Toast.makeText(getApplicationContext(), Integer.toString(count), Toast.LENGTH_SHORT).show();
byte[] byteBuffer =ShortToByte(buffer,bufferReadResult);
try {
os.write(byteBuffer);
} catch (IOException e) {
e.printStackTrace();
}
}else{//count the time
//don't save signal
}
Run Code Online (Sandbox Code Playgroud) 我在编写匹配这些输入的正则表达式时遇到了麻烦:
1.2 \\r
. \\rSomeString
我需要匹配的正则表达式\\r
我正在写这个问题尽管答案很多,stackoverflow因为解决方案对我的问题不起作用.
我有2个列表,List1并且List2.当我dict(zip(List1,List2))在字典中的元素的顺序被扰乱.
print s_key
print value
sorted_dict = {k: v for k,v in zip(s_key,value)}
another_test = dict(zip(s_key,value))
print sorted_dict
print another_test
print zip(s_key,value))
Run Code Online (Sandbox Code Playgroud)
终奌站 :
[2, 1, 3]
[31, 12, 5]
{1: 12, 2: 31, 3: 5}
{1: 12, 2: 31, 3: 5}
[(2, 31), (1, 12), (3, 5)]
Run Code Online (Sandbox Code Playgroud)
我的印象是,[(2, 31), (1, 12), (3, 5)]它将被转换为dict
任何帮助,以了解我在哪里或我做错了会有所帮助!谢谢!
android ×2
python ×2
audio ×1
audiorecord ×1
dictionary ×1
django ×1
list ×1
regex ×1
session ×1
wav ×1