使用python从mailchimp中的特定列表中检索订阅者的所有电子邮件地址(using python to retrieve all email address of subscribers from a specific list in mailchimp)
我试图从Mailchimp中的特定列表(具有唯一的listid)获取订阅者的所有电子邮件地址。
如果我打印正文,则输出为json格式,如下所示。
我正在尝试将json转换为字典。
在它被转换为字典之后,我想获得所有的email_address。
在我获得所有电子邮件地址后,我想使用md5加密它。
但是我遇到错误'TypeError:expected string or buffer'。
我是python的新手,尝试解决它,但不能。 谢谢你看我的问题。
/* My python code */ params = { 'apikey': 'xyz', 'listId': 'abc' } config = MailChimpConfig() endpoint = "https://us5.api.mailchimp.com/3.0/lists/'listId'/members? apikey='apikey'&status=subscribed" while True: response = requests.get(endpoint, auth=('apikey', config.apikey), params=params, verify=False) try: response.raise_for_status() body = response.json dict = json.loads(body) print(dict.members[0].email_address) break except requests.exceptions.HTTPError as err: print "Error: {} {}".format(str(response.status_code), err) print json.dumps(response.json(), indent=4) break except ValueError: print "Cannot decode json, got %s" % response.text break /* end of my python code */ /* If I print body, the output is in json format as below:*/ { - members: [ - { id: "", email_address: "x@hotmail.com", etc:"" }, - { id: "", email_address: "y@gmail.com", etc:"" } /* end of json format */
I am trying to get all email address of subscribers from a specific list (which has a unique listid) in Mailchimp.
If I print body, the output is in json format as below.
I'm trying to convert the json to dictionary.
After it was converted to dictionary, I would like to get all the email_address.
After I get all the email address, I would like to encrypt it using md5.
However I run into error 'TypeError: expected string or buffer'.
I am really new to python, try to solve it but could not. Thanks for looking at my question.
/* My python code */ params = { 'apikey': 'xyz', 'listId': 'abc' } config = MailChimpConfig() endpoint = "https://us5.api.mailchimp.com/3.0/lists/'listId'/members? apikey='apikey'&status=subscribed" while True: response = requests.get(endpoint, auth=('apikey', config.apikey), params=params, verify=False) try: response.raise_for_status() body = response.json dict = json.loads(body) print(dict.members[0].email_address) break except requests.exceptions.HTTPError as err: print "Error: {} {}".format(str(response.status_code), err) print json.dumps(response.json(), indent=4) break except ValueError: print "Cannot decode json, got %s" % response.text break /* end of my python code */ /* If I print body, the output is in json format as below:*/ { - members: [ - { id: "", email_address: "x@hotmail.com", etc:"" }, - { id: "", email_address: "y@gmail.com", etc:"" } /* end of json format */
原文:https://stackoverflow.com/questions/36300318
最满意答案
看看Windows运行时转换。 在您的情况下,您需要AddDeleteThemeTransition (来自MSDN:“为控件添加或删除面板的子项时提供动画过渡行为”)
Take a look at Windows Runtime transitions. In your case you would need AddDeleteThemeTransition (from MSDN: "Provides the animated transition behavior for when controls add or delete children of a panel")
相关问答
更多-
无论如何添加css3过渡动画元素jQuery事件(anyway to add css3 transition animation to element on jQuery event)[2022-10-24]
只要把 -webkit-transition-property: width; -webkit-transition-duration: 500ms; -moz-transition-property: width; -moz-transition-duration: 500ms; 在.box声明中。 你的JS很好。 Just put the -webkit-transition-property: width; -webkit-transition-duration: 500ms; ... -
由于过渡是一种特殊的选择,因此您无法使用转换选择的所有可用方法。 相反,使用transition.each()将处理程序绑定到转换中的元素。 .transition() .each(function () { d3.select(this).on('mouseover', function mouseoverlogic() {}); }); Since transitions are a special kind of selections you cannot use a ...
-
确保过渡完成(Ensure transition completes)[2022-07-24]
在tranistion开始时清除你的听众。 转换结束时附加它 喜欢这个: path2 .data(partition.value(value).nodes) .transition() .duration(1500) .attrTween("d", arcTween) .each("start", funct ... -
创建多行StackPanel(Creating A Multiline StackPanel)[2023-11-09]
我的第一个想法是,这听起来不是很好的地铁。 话虽这么说, 这个图书馆有你想要的。 WrapPanel - 从Silverlight移植的WrapPanel。 允许可变大小的控件并在需要时换行到新行。 有一篇关于它来自何处以及位于此处的示例应用程序的帖子。 如果这不是你需要的,你应该能够很容易地将它修改为你想要的。 My first thought is that that doesn't sound very metro-esk. That being said, this library has what ... -
在Silverlight中,不为canvas / StackPanel触发事件(Drop event not firing for canvas/StackPanel in Silverlight)[2023-08-27]
默认情况下,Silverlight中未实现拖放。 要在Silverlight中使用拖放功能,您必须使用Silverlight Toolkit中的DragDropTargets(PanelDragDropTarget,ListBoxDragDropTarget,...)。 XAMLStackPanel过渡事件(StackPanel Transition Event)[2022-05-12]
看看Windows运行时转换。 在您的情况下,您需要AddDeleteThemeTransition (来自MSDN:“为控件添加或删除面板的子项时提供动画过渡行为”) Take a look at Windows Runtime transitions. In your case you would need AddDeleteThemeTransition (from MSDN: "Provides the animated transition behavior for when controls a ...你可以用一个棘手的方式解决这个问题,如果它是好的,那么它就没问题,否则我会发布另一个。您的StackPanel实际上并未扩展到您标记的区域。 您需要将它们更改为网格,其中包含文本内容的自动大小的ColumnDefinitions和右侧的星形列,或者只需将StackPanel包装在网格中。 还要确保面板的背景不为空(默认) - 使用画笔,即使它是透明的并确保IsHitTestVisible未设置为false - 否则您的面板将不可见以进行测试并且不会是交互式的。 Your StackPanels don't actually extend to the area you marked. You ...过渡结束事件未触发(Transition end event not firing)[2022-03-01]
问题是,在添加时,listener变量是未定义的,因此解决方案是在附加事件侦听器之前声明它。 _animateRipple: function(x, y, color, amplitude) { var ripple = this.$.ripple; // Ripple ended var transitionEndListener = function() { console.log("RIPPLE ENDED"); ripple.classLis ...循环CSS3过渡(Looping CSS3 transition)[2022-02-20]
浏览器在再次添加之前没有机会删除该类,因此它不会重置该样式。 延迟1毫秒修复它...... flipper.one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function () { // remove class when transition is done $('#console').append('[removing class]'); flipper ...相关文章
更多- Python 列表(list)操作
- Hadoop http address绑定内网地址
- Mod_python: The Long Story
- Python内建函数(A)
- A Great List of Windows Tools
- Becoming a data scientist
- python2和python3的区别
- Python 字符串操作
- Python基础 运算
- python字典操作
最新问答
更多- 您如何使用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)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)