如何在python中处理字符串调用模块和函数?(How is calling module and function by string handled in python?)
从Python中使用函数名称的字符串调用模块的函数向我们展示了如何使用getattr(“ bar ”)()调用函数,但这假设我们已经导入了模块foo 。
假如我们可能还必须执行foo的导入(或者从bar import foo ),我们怎么会去调用“foo.bar”的执行呢?
Calling a function of a module from a string with the function's name in Python shows us how to call a function by using getattr("bar")(), but this assumes that we have the module foo imported already.
How would would we then go about calling for the execution of "foo.bar" assuming that we probably also have to perform the import of foo (or from bar import foo)?
原文:https://stackoverflow.com/questions/6643324
更新时间:2023-12-16 06:12
最满意答案
这也在jQuery UI Tabs常见问题中进行了描述。 尝试听取手风琴变化事件并触发地图刷新
google.maps.event.trigger(map, 'resize')
This is described in the jQuery UI Tabs faq as well. Try listening to the accordion change event and triggering a map refresh with
google.maps.event.trigger(map, 'resize')
相关问答
更多-
我没有测试,但这应该可以工作:说你有你的手风琴id#手风琴 $('#accordion').append('
New Paragraph
') .accordion('destroy').accordion(); 基本上,只是摧毁和重新创造手风琴。 更新: 由于这个答案写在手风琴小部件上已经添加了一个refresh()方法。 可以通过调用来调用它: $( ".selector" ).accordion ...New data
-
这真棒,我想我会与世界分享:) 我所要做的就是添加此代码$("#accordion").accordion('activate', 0); 到我的sj:手风琴对象下面的区域。 我的问题是我把这段代码放在我的文档头部,但是我假设元素呈现时有所不同,因此我只能在实际创建后引用此对象。 现在我可以绑定按钮的点击事件来打开不同的手风琴项目。 它的工作就像一个魅力! this is so awesome, i figured i would share with the world :) All i had to d ...
-
如果要将JS添加到.tpl文件,您应该使用{literal}*script*{/literal}标记,或者使用模块中的addJS(path-to-js)方法来显示钩子。 If you want to add JS to a .tpl file you should do it either with the {literal}*script*{/literal} tag, or with the addJS(path-to-js) method in the module to be displayed h ...
-
不敢相信我之前没有发现过......为了实现这一点,每个图像映射都需要一个独特的usemap值 稍微更改第二张图像映射的代码,它完美地工作
CANADA
这也在jQuery UI Tabs常见问题中进行了描述。 尝试听取手风琴变化事件并触发地图刷新 google.maps.event.trigger(map, 'resize') This is described in the jQuery UI Tabs faq as well. Try listening to the accordion change event and triggering a map refresh with google.maps.event.trigger(map, ' ...您需要保存每个地图的中心,然后在新的手风琴被激活后设置它(并且该地图有一个大小,当地图/手风琴被隐藏时,它的计算大小为零,因此标记位于div的左上角)。 一种选择: var maps = []; jQuery("#accordion").accordion({ change: function(event, ui) { for (var i = 0; i < maps.length; i++) { google.maps.event.trigger(maps[i], 'resize' ...jQuery toggleClass在手风琴中有多个部分(jQuery toggleClass with multiple sections within an accordion)[2023-11-27]
你的意思是这样的吗? $(document).ready(function() { $('.accordion').on('click', function() { if($(this).is('.accordion-section-webbutveckling-1')){ $('body').removeClass('webbutveckling-2-body-background granssnittsdesign-body-background', 1000); ...手风琴使用jquery(Accordion using jquery)[2023-03-22]
找到你的DOM元素并调用hide函数。 $("#myElementInsideAccordian").hide(); Find your DOM element and call hide function. $("#myElementInsideAccordian").hide();更新了您的小提琴以回答您在此处显示的问题: https : //jsfiddle.net/4gLaobzh/ 相关变化如下: 取代: google.maps.event.addDomListener(window, 'load', initialize_map); google.maps.event.addDomListener(window, 'resize', function() { var center = map.getCenter(); google.maps.event.trigger ...将其添加到树定义中: autoCollapse: true, 从文档中 :扩展节点时自动折叠所有兄弟节点。 Add this to your tree definition: autoCollapse: true, From the documentation: Automatically collapse all siblings, when a node is expanded.相关文章
更多- Python 字符串操作
- Python字符串格式化
- python2和python3的区别
- Python内建函数(F)
- 探索 Python,第 1 部分: Python 的内置数值类型
- 怎么得到String数组?
- Python内建函数(B)
- redis 字符串(String) SET 操作
- Python资源索引 【转载】
- Python内建函数(H)
最新问答
更多- 您如何使用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)