python 打破双重循环_打破循环,使用Python提升无聊的办公室工作

python 打破双重循环

python 打破双重循环_打破循环,使用Python提升无聊的办公室工作

“ouro7” by Rex Housour, used under CC BY-SA 2.0, cropped original

Rex Housour的 “ ouro7”,根据CC BY-SA 2.0使用 ,已裁剪原始

In the world of programming, there’s something known as a “loop”. Loops are great because, with a few simple lines of code, they can command your computer to do a limitless amount of work. They force your computer into a repeating cycle of manual labor that you, the programmer overlord, benefit from. Boy, aren’t loops great?

在编程领域 ,有一个称为“循环”的东西。 循环之所以出色,是因为用几行简单的代码行,它们就可以命令您的计算机完成无数的工作。 它们迫使您的计算机进入一个重复的手工劳动周期,程序员(您是霸主)将从中受益。 男孩,循环不好吗?

Well, for programmers, sure. Programmers are the ones in charge. The masters. The trouble with loops starts when you aren’t the creator, but the one doing the actual looping. If you have any sort of office job, you are likely entangled in multiple loops. Sending out the same emails day after day. Pulling data from the same source every week. Formatting a monthly report. There’s no end to the insidious loops that arise in office environments.

好吧,对于程序员来说,当然。 程序员是负责人。 大师们。 循环的麻烦始于您不是创建者,而是您进行实际循环的人。 如果您有任何办公室工作,您可能会陷入多个循环。 日复一日发送相同的电子邮件。 每周从同一来源提取数据。 格式化每月报告。 办公环境中出现的隐患循环无止境。

And if you’re stuck in some of these loops, you know just how insidious they can be. Instead of allowing you to exercise your creativity and critical thought, they require nothing more than lifeless, prescribed procedure. They stupefy and lull you into a state of apathy as time passes by in a blur of indistinguishable experience. You neither learn nor grow nor position yourself for promotion. You simply loop.

而且,如果您陷入其中的某些循环中,就会知道它们可能是多么阴险。 除了让您发挥创造力和批判性思维外,他们所需要的只是毫无生气的规定程序。 随着时间的流逝,他们变得愚蠢无比,使您陷入冷漠的状态。 您既不会学习,也不会成长,也不会提高自己的地位。 您只是循环。

So what can be done to awaken from this bureaucratic, Kafkaesque nightmare of ours? Find a new job? Go back to school? Start a business? These are all potentially viable strategies. However, I would like to suggest something a bit less dramatic. No major life-changes required. Very simply, I suggest learning to automate your work with Python.

那么,如何做才能唤醒我们这个官僚,卡夫卡式的噩梦呢? 找新工作? 回到学校? 创业? 这些都是潜在可行的策略。 但是,我想提出一些不太生动的建议。 不需要重大的生活变化。 很简单,我建议学习使用Python自动化您的工作。

If you aren’t familiar, Python is a popular programming language with an endless variety of uses. And for someone with little-to-no programming experience who’s looking to automate their work, Python is ideal because:

如果您不熟悉,Python是一种流行的编程语言,用途广泛。 对于几乎没有编程经验的人来说,他们希望使他们的工作自动化,Python是理想的选择,因为:

  1. It’s generally somewhat easier to learn than many other languages.
  2. It makes it easy to quickly write and test short scripts, perfect for taking your skills to the point of usefulness as fast as possible.
  3. It has a huge community with many packages (collections of code) to make it easier to do almost anything you can think of.
  4. It’s widely used and in high demand, and thus opens the door for all kinds of opportunities later on down the road.
  1. 通常,它比许多其他语言更容易学习。
  2. 它使快速编写和测试短脚本变得容易,非常适合将您的技能尽快带到有用处。
  3. 它有一个庞大的社区,其中包含许多软件包(代码集合),使您几乎可以想到的任何事情都变得更加容易。
  4. 它被广泛使用且需求很高,因此为以后的各种机遇打开了大门。

Hopefully at this point, Python is starting to look pretty attractive. But what’s the catch? Well, here are a couple concerns that often arise:

希望在这一点上,Python开始看起来很有吸引力。 但是有什么收获呢? 好吧,这经常引起一些担忧:

  1. How feasible is it really to learn programming when you’re a busy professional working 40+ hours a week? And not just learn the basics, but learn to actually do useful things?
  2. If you automate the bulk of your work, won’t you be out of a job? Wouldn’t replacing your big expensive human self with a cheap little script be a fundamentally stupid thing to do?
  1. 当您忙于一周工作40个小时以上的专业人士时,学习编程真的有多可行? 不仅学习基础知识,还学会实际做有用的事情吗?
  2. 如果您将大部分工作自动化,您会失业吗? 用廉价的小脚本代替昂贵的大人类自身不是一件愚蠢的事吗?

First, it turns out that you don’t need to be a programming whiz to do useful things. In some extreme cases, I’ve even heard about someone’s entire 40 hour-per-week job being automated in under 50 lines of fairly basic code. Here’s an example of automating a government database query that fits comfortably in under a hundred lines. Nothing too fancy. As long as you’re comfortable with the basics, I guarantee you there’s an ocean of work out there waiting for you to automate it.

首先,事实证明您不需要成为编程专家就可以做有用的事情。 在某些极端的情况下,我什至听说某人每周40个小时的全部工作都用不到50行相当基本的代码自动完成。 这是一个自动化的政府数据库查询的示例 ,该查询可以轻松地适应一百行以下的查询。 没什么好看的。 只要您对基础知识感到满意,我保证您将有大量的工作等待您自动化。

Second, if you automate your work, in all likelihood you will actually have more work to do. How? Let’s say you automate a query like in the example given above. You show this to your boss, who then asks if you can automate 3 other similar queries performed on a regular basis. A website then changes its structure and your code breaks, so now you have to update it. Then your coworkers come up with 5 other mindless tasks of theirs that could be automated. And after a while, as your skills improve, you start coming up with ever more creative applications of programming that you yourself are happy to provide your company with. And now you are off to the races.

其次,如果您使工作自动化,那么实际上您实际上将有更多工作要做。 怎么样? 假设您像上面给出的示例一样自动执行查询。 您将此展示给老板,然后老板会问您是否可以自动执行其他3个定期执行的类似查询。 然后,网站会更改其结构,并且您的代码中断,因此现在您必须对其进行更新。 然后,您的同事提出了他们可以自动执行的其他5个无关紧要的任务。 一段时间之后,随着技能的提高,您开始想出更多具有创意的编程应用程序,您自己很高兴为您的公司提供这些应用程序。 现在您可以参加比赛了。

You still have a lot of work to do, to be sure. But it’s more interesting than what you were doing before. You are learning something new with every script you code. You are building the foundations of a highly valuable skill set in today’s economy. And most importantly, you have broken out of the loop. You now have some measure of control over what you do, or at the very least how you go about doing it. And when you tally up all the hours your programs are saving the company, you’ll have a convincing case to make for a raise. Or if you want to switch jobs, you now have a skill and actual experience applying it which differentiates you from your peers.

当然,您还有很多工作要做。 但这比您之前做的有趣。 您编写的每个脚本都在学习一些新东西。 您正在建立当今经济中极有价值的技能基础。 最重要的是,您已经脱离了循环。 现在,您可以控制自己的工作方式,或者至少可以控制自己的工作方式。 而且,当您计算出程序在拯救公司的所有时间后,就会有令人信服的理由来加薪。 或者,如果您想换工作,那么您现在已经拥有运用该技能的技能和实际经验,这使您有别于同行。

Of course, there’s always what I call the Tetris Strategy, which is where you automate all your work, don’t tell anybody, and pass your newfound free time mastering a classic and timeless video game in utter secrecy. I wouldn’t necessarily recommend this route, but if you want to try and pull it off, more power to you my friend.

当然,总有我所说的“俄罗斯方块策略”,在这里您可以自动化所有工作,不告诉任何人,并通过新发现的业余时间完全保密地掌握经典且永恒的视频游戏。 我不一定会推荐这条路线,但是如果您想尝试将其拉开,我的朋友将为您提供更多的功能。

翻译自: https://www.pybloggers.com/2016/12/break-the-loop-and-level-up-your-boring-office-job-with-python/

python 打破双重循环