怎么样在 Windows 上安装 Python | Linux 中国
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/a51abd6bb5574f1fa97fa7dae01cf056~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723903753&x-signature=%2BfXk6Z0MrBCFioxzjKCJKJ0C7Ig%3D" style="width: 50%; margin-bottom: 20px;"></div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">安装 Python,<span style="color: black;">起步</span> IDE,<span style="color: black;">而后</span>你就<span style="color: black;">能够</span>在 Windows 系统下进行编程了。</p><span style="color: black;">源自</span>:https://linux.cn/article-12335-1.html作者:Seth Kenlon译者:011011100010110101101111<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">(本文字数:4184,阅读时<span style="color: black;">成长</span>约:6 分钟)</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">你<span style="color: black;">是不是</span>想学习编程呢?<span style="color: black;">能够</span>从 Python <span style="color: black;">起始</span>,它<span style="color: black;">由于</span>简洁的语法和面向对象的特性而非常受欢迎,是最<span style="color: black;">平常</span>的编程语言之一。<span style="color: black;">况且</span> Python 是一门解释型语言,这<span style="color: black;">寓意</span>着你无需<span style="color: black;">晓得</span><span style="color: black;">怎样</span>把 Python 代码编译为<span style="color: black;">设备</span>语言 —— Python 会帮你做到这一点,从而使你能够在编写代码的<span style="color: black;">同期</span>立即进行测试。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">然则</span>你<span style="color: black;">亦</span><span style="color: black;">不可</span>仅仅<span style="color: black;">由于</span> Python 学习起来简单而低估了它强大的潜能,无论是在 电影 工作室 、视频游戏工作室,还是在金融<span style="color: black;">公司</span>、IT <span style="color: black;">公司</span>、制造业,都有 Python 的身影,<span style="color: black;">乃至</span><span style="color: black;">非常多</span>业余<span style="color: black;">兴趣</span>者、 艺术家 、教师和许多其他人都<span style="color: black;">运用</span> Python。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">另一方面,Python <span style="color: black;">亦</span>是一门严肃的编程语言,学习它<span style="color: black;">必须</span>付出和实践。还有,你什么都不<span style="color: black;">必须</span>马上做,就几乎<span style="color: black;">能够</span>在任何计算机平台上安装并尝试<span style="color: black;">运用</span> Python ,<span style="color: black;">因此呢</span>,<span style="color: black;">倘若</span>你<span style="color: black;">运用</span>的是 Windows 操作系统,那本文正适合你。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span>你<span style="color: black;">运用</span>的是开源的 Linux 操作系统,那你<span style="color: black;">能够</span> 在 Linux 上安装 并 尝试<span style="color: black;">运用</span> Python 。</p>
<h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">怎样</span>获取 Python</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">你<span style="color: black;">能够</span>从 Python 官方网站 上去下载 Python。在 Python 官方网站下载页,<span style="color: black;">能够</span>将鼠标悬停在 “Downloads” 按钮上,待菜单展开后,再将鼠标悬停在 “Windows” 选项,最后点击按钮就<span style="color: black;">能够</span>下载最新版的 Python 了。</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p6-sign.toutiaoimg.com/pgc-image/de1549e6f55c45fe8b126d45f7a3e7b9~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723903753&x-signature=GXtzK0v%2FjzaDoB6b5zQdnUG51mU%3D" style="width: 50%; margin-bottom: 20px;">
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Downloading Python on Windows</p>
</div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">或</span>你<span style="color: black;">亦</span><span style="color: black;">能够</span>直接点击 “Downloads” 按钮,<span style="color: black;">而后</span>在下载页中<span style="color: black;">选取</span>特定的版本去下载。</p>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">安装 Python</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">下载好安装包后,直接打开就<span style="color: black;">能够</span><span style="color: black;">起步</span>安装程序了。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">安装时,<span style="color: black;">选取</span>默认的安装路径比较好,最重要的是要将 Python 添加到搜索路径中,否则 Python 应用程序不<span style="color: black;">晓得</span>它该从哪里找到 Python <span style="color: black;">必要</span>的运行时环境;默认认安装时并<span style="color: black;">无</span>选中这一项,<span style="color: black;">必须</span>手动勾选安装窗口的 “Add Python 3.7 to Path” ,<span style="color: black;">而后</span>点击继续。</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p26-sign.toutiaoimg.com/pgc-image/ded94e8f678a40d0a771d444070c318b~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723903753&x-signature=t1FHSDeK2lT2%2FMQVt4cNOXx6Bcc%3D" style="width: 50%; margin-bottom: 20px;">
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Select "Add Python 3 to PATH"</p>
</div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">因为</span> Windows <span style="color: black;">必须</span>经过你的<span style="color: black;">准许</span>才会<span style="color: black;">准许</span>安装非微软官方发行的应用程序,<span style="color: black;">因此呢</span>你<span style="color: black;">必要</span>要在弹出 “User Account Control”(UAC) 系统提示窗口的时候 点击 “Yes” 来继续完成安装。</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/cfd856b82d09425a9f9a4dfcf6ba4f45~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723903753&x-signature=QHohpuVn%2FxJAfOkl0c8lGnEAnlk%3D" style="width: 50%; margin-bottom: 20px;">
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Windows UAC</p>
</div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">此时</span>候你就<span style="color: black;">必须</span>耐心等待,系统会自动将 Python 软件包分发到合适的位置,等待过后,<span style="color: black;">亦</span>就<span style="color: black;">寓意</span>着你<span style="color: black;">已然</span>成功的安装了 Python ,你就<span style="color: black;">能够</span>愉快的与 Python 玩耍了!</p>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">安装一个 IDE</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">虽然说你仅<span style="color: black;">必须</span>一个文本编辑器,就<span style="color: black;">能够</span><span style="color: black;">起始</span>编写 Python 代码了,<span style="color: black;">然则</span>我依然<span style="color: black;">意见</span>你<span style="color: black;">运用</span> IDE(集成<span style="color: black;">研发</span>环境)来进行<span style="color: black;">研发</span>,<span style="color: black;">这般</span><span style="color: black;">研发</span>起来就会变得方便<span style="color: black;">非常多</span>。IDE 会将文本编辑器和<span style="color: black;">有些</span>好用的 Python 功能集成到<span style="color: black;">一块</span>,<span style="color: black;">运用</span>起来非常友好。你<span style="color: black;">能够</span><span style="color: black;">思虑</span><span style="color: black;">选取</span> IDLE 3 <span style="color: black;">或</span> NINJA-IDE 来作为你的 IDE。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">IDLE 3</strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Python 自带一款 IDE,名字叫 IDLE。虽然你<span style="color: black;">能够</span><span style="color: black;">运用</span>任何文本编辑器编写 Python 代码,但 IDE <span style="color: black;">一般</span>会<span style="color: black;">供给</span> Notepad++ 之类的纯文本编辑器所<span style="color: black;">无</span>的代码高亮、语法检测等功能,<span style="color: black;">乃至</span>在 IDE 里<span style="color: black;">能够</span>直接<span style="color: black;">经过</span>鼠标点击 “Run” 按钮就能快速运行 Python 代码。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">想要<span style="color: black;">起步</span> IDLE ,<span style="color: black;">能够</span>点击 Windows 的 “<span style="color: black;">起始</span>” (<span style="color: black;">或</span> “Windows”)按钮,<span style="color: black;">而后</span>输入 python 来进行搜索。<span style="color: black;">此时</span>候可能会搜索到多个选项,<span style="color: black;">选取</span> IDLE <span style="color: black;">起步</span>就好了。</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/325bd509d7b6414cbf5471025ddb63a4~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723903753&x-signature=cFJ7MSDccP%2Ff69fDRcEZzAyKol4%3D" style="width: 50%; margin-bottom: 20px;">
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">IDLE 3 IDE</p>
</div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span>在 “<span style="color: black;">起始</span>” 菜单中<span style="color: black;">无</span>搜到,你<span style="color: black;">亦</span><span style="color: black;">能够</span>在 “<span style="color: black;">起始</span>” 菜单输入 cmd (或<span style="color: black;">同期</span>按下键盘 win + R 键) 来<span style="color: black;">起步</span> Windows 命令提示符,<span style="color: black;">而后</span>输入下面命令来<span style="color: black;">起步</span> IDLE :</p><span style="color: black;">C</span>:\<span style="color: black;">Windows</span>\<span style="color: black;">py</span><span style="color: black;">.exe</span>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span>还是<span style="color: black;">没法</span><span style="color: black;">起步</span>的话,可是试着重新安装 Python ,安装时记得务必要在安装向导中选中 “Add Python to PATH”。<span style="color: black;">仔细</span>说明,<span style="color: black;">能够</span>参考 Python 官方文档 。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">Ninja-IDE</strong></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span>你<span style="color: black;">已然</span>有<span style="color: black;">有些</span>编程经验,<span style="color: black;">况且</span>你觉得 IDLE 对你<span style="color: black;">来讲</span>有些简陋的话,你<span style="color: black;">亦</span><span style="color: black;">能够</span>试试 Ninja-IDE 。 Ninja-IDE 是一款非常出色的 Python IDE,它<span style="color: black;">拥有</span>代码高亮功能,并且它会自动帮你检测诸如拼写错误、引号或括号缺失以及其他语法错误。<span style="color: black;">况且</span>它还<span style="color: black;">能够</span><span style="color: black;">表示</span>行号(调试的时候会非常有用)、缩进标记<span style="color: black;">乃至</span><span style="color: black;">能够</span>直接<span style="color: black;">经过</span>点击 “Run” 按钮来运行你的代码。</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/c85ce39978d640fa9c21beac87d189dc~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723903753&x-signature=gtBTCrPAtPJTB3ACEW9NVZfMdQw%3D" style="width: 50%; margin-bottom: 20px;">
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Ninja-IDE</p>
</div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span>要安装 Ninja-IDE ,你<span style="color: black;">能够</span><span style="color: black;">拜访</span> Ninja-IDE 的官网 下载 Windows 安装程序 。<span style="color: black;">过程</span>跟安装 Python 大同小异:下载安装包、<span style="color: black;">准许</span> Windows 安装非微软官方的应用程序,<span style="color: black;">而后</span>等待完成安装<span style="color: black;">就可</span>。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Ninja-IDE 安装完成后,双击 Windows 桌面或<span style="color: black;">起始</span>菜单下的 Ninja-IDE 就<span style="color: black;">能够</span><span style="color: black;">起步</span>了。</p>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">告诉 Python 怎么做</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">关键字能让 Python <span style="color: black;">晓得</span>你想要做什么。在 IDLE <span style="color: black;">或</span> Ninja-IDE ,打开 “文件” 菜单,创建一个新文件。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在 Ninja-IDE 中,不要创建一个新项目,而是单独创建一个新文件就<span style="color: black;">能够</span>了。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在你用 IDLE <span style="color: black;">或</span> Ninja-IDE 新建的文件中,输入以下代码:</p><span style="color: black;">print</span>(<span style="color: black;">"Hello world."</span>)
<span style="color: black;">倘若</span>你<span style="color: black;">运用</span>的是 IDLE ,请点击 “运行” 菜单,<span style="color: black;">选取</span> “运行模块” 选项来运行你的程序。<span style="color: black;">倘若</span>你<span style="color: black;">运用</span>的是 Ninja ,请单击左侧按钮栏中的 “运行文件” 按钮。<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p26-sign.toutiaoimg.com/pgc-image/4097511417344e799e2c302031cab9fa~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723903753&x-signature=u1aMbcCiGos8ZzIsVqNDy0PPSzQ%3D" style="width: 50%; margin-bottom: 20px;">
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Running code in Ninja-IDE</p>
</div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">任何时间当你想要执行代码,IDE 都会提示你先<span style="color: black;">保留</span>当前正在处理的文件,<span style="color: black;">而后</span>再继续。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">print 关键字会告诉 Python 打印出你在括号和引号中输入的所有文本。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">然则</span>别高兴地太早,Python 的核心库<span style="color: black;">亦</span>就只能<span style="color: black;">拜访</span> print 和 help 之类的基本关键字、函数等。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">倘若</span>想要<span style="color: black;">运用</span><span style="color: black;">更加多</span>的关键字和函数,你就<span style="color: black;">必须</span><span style="color: black;">运用</span> import 关键字去加载它们。好了,先在你的 IDLE <span style="color: black;">或</span> Ninja 中新建一个文件,命名为 pen.py 。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;">警告</strong>:不要把你新建的文件命名为 turtle.py ,<span style="color: black;">由于</span> turtle.py 是<span style="color: black;">包括</span>了你要<span style="color: black;">掌控</span>的 turtle 程序的文件名<span style="color: black;">叫作</span>,<span style="color: black;">运用</span> turtle.py <span style="color: black;">做为</span>文件名会让 Python 感到困惑,<span style="color: black;">由于</span>它以为你想要引入你自己的文件。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在你新建的文件中输入一下代码,并运行:</p><span style="color: black;">import</span> turtle
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Turtle 是一个用起来非常有意思的模块. 把这段代码添加到你的文件内:</p><span style="color: black;">turtle</span><span style="color: black;">.begin_fill</span>()
<span style="color: black;">turtle</span><span style="color: black;">.forward</span>(100)
<span style="color: black;">turtle</span><span style="color: black;">.left</span>(90)
<span style="color: black;">turtle</span><span style="color: black;">.forward</span>(100)
<span style="color: black;">turtle</span><span style="color: black;">.left</span>(90)
<span style="color: black;">turtle</span><span style="color: black;">.forward</span>(100)
<span style="color: black;">turtle</span><span style="color: black;">.left</span>(90)
<span style="color: black;">turtle</span><span style="color: black;">.forward</span>(100)
<span style="color: black;">turtle</span><span style="color: black;">.end_fill</span>()
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">来<span style="color: black;">瞧瞧</span>你<span style="color: black;">能够</span><span style="color: black;">运用</span> turtle 模块来绘制出<span style="color: black;">那些</span>图案。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">想要清空 turtle 绘制的区域的话,你<span style="color: black;">能够</span><span style="color: black;">运用</span> turtle.clear() 函数。那你<span style="color: black;">晓得</span> turtle.color("blue") 是用来做什么的吗?</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">咱们</span>来试一下更<span style="color: black;">繁杂</span>点的程序:</p><span style="color: black;">import</span>turtle as t<span style="color: black;">import</span> time
t.color(<span style="color: black;">"blue"</span>)
t.begin_fill()
counter = <span style="color: black;">0</span>
<span style="color: black;">while</span> counter < <span style="color: black;">4</span>:
t.forward(<span style="color: black;">100</span>)
t.<span style="color: black;">left</span>(<span style="color: black;">90</span>)
counter = counter+<span style="color: black;">1</span>
t.end_fill()
time.sleep(<span style="color: black;">2</span>)
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">给你个挑战,试试修改代码,让它得到下图所示的结果:</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/pgc-image/2a7f76438fe24720ac2c893baaf5594e~noop.image?_iz=58558&from=article.pc_detail&lk3s=953192f4&x-expires=1723903753&x-signature=S25v9lyDdqziAHMUR8tz2WBSevk%3D" style="width: 50%; margin-bottom: 20px;">
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Example Python turtle output</p>
</div>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">当你完成这段代码后,你就<span style="color: black;">能够</span>继续学习<span style="color: black;">更加多</span>有意思的模块了。这个 入门级骰子游戏 <span style="color: black;">便是</span>个不错的<span style="color: black;">起始</span>。</p>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">保持 Pythonic</h1>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">Python 是一门非常有趣的语言,它的模块几乎能实现所有你想要实现的功能。正如你所看到的,Python 入门很容易,只要你对自己有耐心,<span style="color: black;">火速</span>就会<span style="color: black;">发掘</span>自己在理解和编写 Python 时能像写汉字<span style="color: black;">同样</span>流畅。你<span style="color: black;">能够</span>多阅读关于 Python 的<span style="color: black;">文案</span> ,试着自己编写<span style="color: black;">有些</span>小片段,<span style="color: black;">而后</span><span style="color: black;">瞧瞧</span> Python 会执行出什么结果。<span style="color: black;">倘若</span>想要把 Python 真正融合到你<span style="color: black;">实质</span>工作中,你<span style="color: black;">能够</span>试试 Linux ,Linux <span style="color: black;">拥有</span>在本地可编写脚本的功能,而其他系统却<span style="color: black;">无</span>。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">祝你好运,记得保持 Pythonic。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">via: https://opensource.com/article/19/8/how-install-python-windows</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">作者: Seth Kenlon 选题: lujun9972 译者: LiuWenlong 校对: wxy</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">本文由 LCTT 原创编译, Linux中国 荣誉推出</p>
<h1 style="color: black; text-align: left; margin-bottom: 10px;">点击“<span style="color: black;">认识</span><span style="color: black;">更加多</span>”可<span style="color: black;">拜访</span>文内链接</h1>
我赞同你的看法,你的智慧让人佩服,谢谢分享。 你的话深深触动了我,仿佛说出了我心里的声音。 网站建设seio论坛http://www.fok120.com/ 软文发布论坛开幕式圆满成功。 http://www.fok120.com
页:
[1]