首页 \ 问答 \ Python非线性切片(Python non-linear slicing)

Python非线性切片(Python non-linear slicing)

给出一个列表a ,我可以通过这样做来切片:

a[start:end:step]

然而,这只是线性切片。 例如,我想选择2的幂的索引。不幸的是,这不起作用:

a[slice(2**x for x in range(len(a))]

当需要非线性切片时,是否有避免循环的方法?

编辑 :主要是我需要这个修改列表。 例如

a[*non-linear-slicing*] = [*list-with-new-values*]

Given a list a, I can slice it by doing:

a[start:end:step]

However this is only linear slicing. For instance, I would like to select the indexes that are powers of 2. Unfortunately this does not work:

a[slice(2**x for x in range(len(a))]

Is there a way to avoid loops when non-linear slicing is required?

EDIT: mainly I need this to modify the list. E.g.

a[*non-linear-slicing*] = [*list-with-new-values*]

原文:https://stackoverflow.com/questions/47012837
更新时间:2021-05-02 21:05

最满意答案

通常这在大多数安装程序中被称为CustomAction。 根据我的经验,在使用CustomActions安装结束时,必须将其他MSI链接在一起,因为一次不允许运行多个MSI安装程序。


Generally this is referred to as a CustomAction in most installers. In my experience, additional MSI's must be chained together at the end of the installation using CustomActions, as it is not allowed to run more than one MSI installer at a time.

相关问答

更多
  • 当您更改安装项目中的Version属性时,Visual Studio应该提示您也更改ProductCode 。 你必须这样做。 然后,您还必须将RemovePreviousVersion属性设置为true。 确保UpgradeCode保持不变。 这可能是最简单的方法,通过阅读你的问题,你正在寻找什么。 请注意,这更像是卸载,然后重新安装,而不是“升级”本身。 When you change the Version property in your Setup project, Visual Studio s ...
  • 不要使用ServiceControl元素,因为它将启动和停止服务。 通过调用它,您要求安装程序使用服务执行某些操作。 你只需要调用ServiceInstall来创建一个服务。 正如Stefan Wanitzek建议的那样,您应该在ServiceInstall的Start属性中使用需求。 这是为了让用户重新启动计算机时服务不会开始运行。 如果您的安装程序也将安装.exe作为安装服务的文件。 我会建议使用以下代码:
    这些声音就像它们提供了依赖关系。 由于您提供.exe文件,我建议您创建一个先决条件并将其包含在您的项目中。 这将导致首先安装它们,并且您的主.msi(或InstallScript)项目内容将跟随。 (如果您只提供.msi文件,则可能需要记录您的依赖项。您可以查看Chained .MSI Packages支持,但它并不适合处理依赖项。) These sound like they provide dependencies. Since you deliver a .exe file, I would sugg ...
  • 看看Process.Start 。 Process.Start("path to msi"); 要获取文件的路径,可以使用FileDialog类(假设为winforms)。 OpenFileDialog openFileDialog1 = new OpenFileDialog(); if(openFileDialog1.ShowDialog() == DialogResult.OK) { Process.Start(openFileDialog1.FileName); } Look at Pro ...
  • 使用Wix项目的部署工具基础(DTF)中的“Microsoft.Deployment.WindowsInstaller.dll”。 DTF为msi.dll的大部分提供了一个托管包装器。 Wix还提供有用的文档。 这里使用DTF是我如何在C#中访问msi的版本号 using Microsoft.Deployment.WindowsInstaller; namespace Msi.Tables { public class PropertyTable { public stat ...
  • 通常这在大多数安装程序中被称为CustomAction。 根据我的经验,在使用CustomActions安装结束时,必须将其他MSI链接在一起,因为一次不允许运行多个MSI安装程序。 Generally this is referred to as a CustomAction in most installers. In my experience, additional MSI's must be chained together at the end of the installation using ...
  • 记录卸载并通读它。 您可能具有引用计数和/或组件规则违规,这会导致Windows Installer将文件置于非常谨慎的状态。 Log the uninstall and read through it. You may have reference counting and/or component rule violations that causes Windows Installer to leave the files out of an abundance of caution.
  • 这实际上取决于你要通过签署MSI来实现的目标。 如果你只是想让它安装,你已经完成了; Windows不允许安装未签名的MSI文件。 如果您尝试获得绿色UAC提示,则签名证书需要是可验证的。 这可以通过适当地购买证书,或者在每台目标计算机上安装自签名证书或其根目录来完成。 (后者在企业内部对于企业自己签署的项目很常见。) 但是,如果你真的想要确保安全,那么你很快就会遇到鸡与蛋的问题。 使用颁发给X的证书签名的文件应该确认来自X的位,并允许用户确定X是否值得信任。 部分原因是要知道其他任何人都无法使用声称已经发 ...
  • 如果您正在使用版本视图的“链式MSI包”区域,则通过MsiEmbeddedChainer表使用嵌入式链接。 我还没有找到有关其限制的明确文档,但它有几个。 您看到的相关内容是它不会从另一个chainer中启动嵌入式chainer。 也许这是因为如果外部chainer具有后续包,则它不知道收回事务的所有权,并且在内部chainer发布(或提交)事务之前不能这样做; 这将导致对MsiJoinTransaction的phChangeOfOwnerEvent的评论进行回滚。 我们从经验中了解到,外部或引导的chai ...
  • 好的......这就是我解决这个问题的方法......而不是直接调用msiexec ...我通过exe包装器调用它... exe包装器通过自定义操作调用...我也签了exe包装器,所以我看到正确的证书... Okay... This is how I have resolved this... Rather than directly calling the msiexec... I am calling it through an exe wrapper... The exe wrapper is cal ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。