首页 \ 问答 \ 如何在Python中使用切片来选择其他的(How to select every other using slicing in Python)

如何在Python中使用切片来选择其他的(How to select every other using slicing in Python)

我想知道如何从python中分配给变量的数字中提取其他数字(从第二个开始)。

例如,我想要这样:

a= '102030'

成为

a= '000'

我听说这是可以使用“切片”,我只是不知道如何。

任何帮助表示赞赏!


I am wondering how I can extract every other digit (starting with the second) from a number assigned to a variable in python.

For example, I want this:

a= '102030'

to become

a= '000'

I hear this is possible to do using "slicing," I'm just not sure how.

Any help is appreciated!


原文:https://stackoverflow.com/questions/43905817
更新时间:2022-05-31 11:05

最满意答案

对您的成品进行负载测试并证明访问不适用于为网站提供动力。

编写代码,以便您可以轻松更换数据库后端。 然后,当访问失败时,将数据迁移到真正的数据库,或者MySQL,如果必须的话。

以下是一些Microsoft Web服务器压力工具

为了记录,可以将大多数SQL命令发送到数据库,而不是保持活动连接处于打开状态,从而一次允许远远超过6或7个连接,但事实是访问并不意味着这样做。 因此,“它工作正常”的意思就好像说用胶带清理地板很好:它可以工作,但不适合工作。

更新问题的更新答案:

真的,这里的关键是在代码中分离数据访问。 您应该能够在任何数量的DBMS中或多或少地拥有数据库结构。 事情可能会变得复杂,但是表格图应该是通用的。 然后应该访问不起作用,决定使用不同的数据库。

访问可用于高流量的网站。 通过仅使用SQL语句的例程,我能够建立一个电子商务网站,每年销售额达到几百万,并且每个月有60,000个访问者。 这是可能的,但可能并不理想。 这些数字并不是很大,但对于我参与过的任何网站来说,它们是最大的。

如果IT经理太忙而无法维护另一台服务器,或者不愿花时间配置其他服务器,请保持访问权限。 最终猜测什么都不做,并且测试告诉你你需要知道的一切。 测试并对结果做出决定。


Do a load test on your finished product and prove that Access isn't meant for powering websites.

Write your code so that you can change out the database back end easily. Then when access fails migrate your data to a real db, or MySQL if you have to.

Here are some Microsoft Web server stress tools

For the record, it is possible to send mostly SQL commands to the database and not keep an active connection open, thereby allowing far more than 6 or 7 connections at once, but the fact is that access just isn't meant to do it. So the "it works fine" point is like saying it is fine to clean your floor with sticky tape: it works, but isn't the right tool for the job.

UPDATED ANSWER TO UPDATED QUESTION:

Really the key here is the separation of data access in your code. You should be able to more or less have the data database structure in any number of DBMS. Things can get complicated, but a map of tables should be universal. Then should access not work, decide to use a different database.

Access CAN be used in kinda high traffic sites. With the SQL statement only routines I was able to build an e-commerce site that did a couple million a year in sales, and had 60K visitors a month. It is possible, but maybe not ideal. Those aren't big numbers, but they are the biggest for any site I have been a part of.

Keep access if IT Manager is too busy to maintain another server, or unwilling to spend time configuring one. Ultimately guessing does nothing, and testing tells you everything you need to know. Test and make decisions on the results.

相关问答

更多
  • 下面的例子可能会让你想到执行从MS Access到SQL Server的数据迁移。 该示例使用MS Access 2010和SQL Server 2008 R2数据库。 该软件包是用SSIS 2008 R2编写的。 与以前提供的解决方案不同,此答案不使用SQL Server导入和导出向导,并且该包是从头开始构建的。 循序渐进的过程: 我们假设Access表格如屏幕截图# 1所示,其中一个名为Companies的表格包含两个非标准化的行。 并假设SQL Server中的表结构如屏幕截图# 2和# 3所示,其中 ...
  • 在Access中,通过ODBC链接您要上载到的SQL Server中的表。 然后创建并运行追加查询以在链接表中插入数据。 In Access, link via ODBC the tables in SQL Server you wish to upload to. Then create and run append queries to insert the data in the linked tables.
  • 不幸的是,访问受到新闻和传闻不好的影响,其中大部分确实是非常过时的。 这里有一些有用的注释: MS Access 2003 - 学习高级VBA的好书 MS Access(JET)适合多用户访问吗? 为多用户访问设置一个MS-Access数据库 https://stackoverflow.com/questions/469799/what-are-the-appropriate-uses-for-ms-access ms-access标签中还有许多其他有用的线程,这些线程由具有丰富的Access经验的人编写, ...
  • 好吧事实证明这是我自己的错。 对于其他任何有类似(看似)问题的人来说,原因是我在push.students上设置了一个触发器,它将合并(以及其他东西)运行到dbo.students中。 显然,触发器是由'push'用户执行的,他没有权限修改dbo.students - 因此失败了。 删除了触发器,它全部排序! 更新:我仍然需要触发器,因此我将其设置为在不同的用户下运行 - dbo帐户有权执行需要执行的操作。 这避免了为我的受限“推送”帐户提供开放式权限的麻烦: CREATE TRIGGER
  • 对您的成品进行负载测试并证明访问不适用于为网站提供动力。 编写代码,以便您可以轻松更换数据库后端。 然后,当访问失败时,将数据迁移到真正的数据库,或者MySQL,如果必须的话。 以下是一些Microsoft Web服务器压力工具 为了记录,可以将大多数SQL命令发送到数据库,而不是保持活动连接处于打开状态,从而一次允许远远超过6或7个连接,但事实是访问并不意味着这样做。 因此,“它工作正常”的意思就好像说用胶带清理地板很好:它可以工作,但不适合工作。 更新问题的更新答案: 真的,这里的关键是在代码中分离数据 ...
  • 这将针对MS Access OleConnection连接运行: SELECT fld1, fld2 INTO accessTable FROM [sql connection string].sqltable 例如: SELECT * INTO newtable FROM [ODBC;Description=Test;DRIVER=SQL Server;SERVER=server\SQLEXPRESS;UID=uid;Trusted_Connection=Yes;DATABASE=Test].tab ...
  • MS KB也显示了一些原因和修复 原因: 出现此问题的原因是卸载SQL Server实例时删除了WMI提供程序。 32位实例和64位SQL Server实例共享相同的WMI配置文件。 此文件位于%programfiles(x86)%文件夹中。 解析度: 在命令提示符下运行命令 mofcomp“%programfiles(x86)%\ Microsoft SQL Server \ number \ Shared \ sqlmgmproviderxpsp2up.mof” 您的电话号码取决于您使用的版本 Micr ...
  • 作为一般规则,在迁移到后端的SQL服务器之后,则是一个典型且常见的开放式reocrdset Set rst = CurrentDb.OpenRecordset("Contacts") 需要成为 Set rst = CurrentDb.OpenRecordset("Contacts", dbOpenDynaset, dbSeeChanges) 所以,在你的情况下: Set rc = CurrentDb.openRecordset("SELECT * FROM DBLog WHERE false" dbOp ...
  • 因为SQL Server确实作为一个单独的进程运行,所以缓存结果,在不被查询时使用ram和处理能力等等,如果另一台计算机只有很少的RAM或非常慢的处理器(或者甚至更重要的是单核处理器),我可以看到SQL Server实际上比MS Access使用更慢的情况。 如果没有关于硬件设置的信息,大约有多少百分比的应用程序依赖于查询数据库等,我不确定这个问题是否可以轻松解决。 MS SQL Server 2005 Express至少需要512 MB内存(请参阅http://www.microsoft.com/sqls ...

相关文章

更多

最新问答

更多
  • 获取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的基本操作命令。。。