由GCM推送Android应用程序的通知(Push notification for android app by GCM)
我正在研究Android应用程序的事件提醒,这个应用程序只显示事件列表和有关它的详细信息..某些事件的日期是更改。
我需要推送通知以提醒用户有关活动日期的信息
阅读Google云端消息传递(GCM)后,我感到很困惑
是否有必要要求用户通过应用程序输入姓名或电子邮件? 我不需要那个!
我在哪里可以写一个新的通知“消息”来发送它?
谢谢 ,
I am working on android app for events reminder , this app only display event as list and details about it .. some event's date is change .
I need to push notification to remind a user about event date
I'am Confused when read about Google Cloud Messaging ( GCM )
Is it necessary to request from the user to enter name or email through the application ? I don't need that !
where can I write a new notification "message" to send it ?
Thank you ,
原文:https://stackoverflow.com/questions/35894906
满意答案
你正在用另一个影子你的for-loop
i
:for i in range(1,3): # type(i) is int … for i in scan1: … # type(i) is str … diskchange[i] = disk # i is str() here, so it yells at you!
将你的内循环索引从
i
更改为j
,你应该没问题。在python中,变量的可见性超过了一个完整的函数,而不是一个块。 因此,当您在块中定义变量时,它在块之后仍然可见:
i = 'foobar' print(i, type(i)) for i in range(100): pass print(i, type(i))
会给:
foobar str 100 int
因此在重用变量名时要小心。
要解决您的问题,只需将索引名称更改为
j
:for j in scan1: if j not in scan2: result = result + j
奖金:
在下面的代码片段中,您将通过将整个内容发送到shell来读取脚本的完整内容以执行它:
with open('removeslot%d.sh' %i, 'rb') as f: script = f.read() subprocess.call(script, shell=True)
这实际上是过度设计,你可以简单地做:
subprocess.call('removeslot%d.sh' % i, shell=True)
执行脚本(或
'bash removeslot%d.sh' % i
,以防您的.sh
不可执行)。 还要注意你再次遮蔽一个符号:file
是用于处理全局可用文件的类。 改用f
!HTH
You're shadowing your for-loop
i
with anotheri
:for i in range(1,3): # type(i) is int … for i in scan1: … # type(i) is str … diskchange[i] = disk # i is str() here, so it yells at you!
Change your inner loop's index from
i
toj
and you should be fine.In python, the variable's visibility is over a full function, not a block. So when you're defining a variable within a block, it's still visible after the block:
i = 'foobar' print(i, type(i)) for i in range(100): pass print(i, type(i))
will give:
foobar str 100 int
so be careful when reusing variable names.
To fix your issue, just change the index name to
j
:for j in scan1: if j not in scan2: result = result + j
bonus:
In the following snippet, you're reading the full content of a script to execute it by sending its whole content to a shell:
with open('removeslot%d.sh' %i, 'rb') as f: script = f.read() subprocess.call(script, shell=True)
this is actually over engineered, you can simply do:
subprocess.call('removeslot%d.sh' % i, shell=True)
to execute the script (or
'bash removeslot%d.sh' % i
in case your.sh
is not executable). Also beware that you're again shadowing a symbol:file
is the class for handling files that is globally available. Usef
instead!HTH
相关问答
更多Python - > TypeError:list indices必须是整数,而不是str(Python -> TypeError: list indices must be integers, not str)
Python:列表索引必须是整数,而不是str?(Python: list indices must be integers, not str?)
Python chatbot - TypeError:list indices必须是整数,而不是str(Python chatbot - TypeError: list indices must be integers, not str)
直方图:“TypeError,列表索引必须是整数,而不是str”(Histograms: “TypeError, list indices must be integers, not str”)
带有Dataframe的TypeError:列表索引必须是整数或切片,而不是str(TypeError with Dataframe: list indices must be integers or slices, not str)
TypeError:列表索引必须是整数,而不是str(实际上是boolean convertion)(TypeError: list indices must be integers, not str (boolean convertion actually))
Python3 TypeError:列表索引必须是整数或切片,而不是str(Python3 TypeError: list indices must be integers or slices, not str)
在列表上混淆:TypeError:list indices必须是整数,而不是str(Confused on lists: TypeError: list indices must be integers, not str)
TypeError:list indices必须是整数或切片,而不是str dictionary python(TypeError: list indices must be integers or slices, not str dictionary python)
TypeError:列表索引必须是整数,而不是Flask App中的str(TypeError: list indices must be integers, not str in Flask App)
相关文章
更多nslocal notification
开发android App干坏事(一)
android APP 中微信分享功能实现 的总结
android APP 中微信分享功能实现 的总结
HTML5 Notification 桌面提醒功能 API
Android 社交类APP 豆瓣同城Lite(安全,无广告)
Android app开发实战第二季【公开课视频下载】
Android app开发实战第一季【公开课视频下载】
微信公众平台如何与Web App结合?
微信公众平台如何与Web App结合
最新问答
更多您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
在计算机拍照在哪里进入
使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
单页应用程序:页面重新加载(Single Page Application: page reload)
在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!