Mistakes in Hello World
今天在cmd中用Python写第一行代码“Hello World”出现错误。
写好的源码“HelloWorld.py”存放于“ F:\learning\python test ”文件夹中。 最开始我写的代码:C:\Users\lenovo>python HelloWorld.py
然后出现如下错误:

错误原因:想在命令行中运行py文件需要写上完整的py文件目录,我在Users\lenovo中执行 “python HelloWorld.py”在当前目录下是找不到这个文件的。 解决办法:1. 切换到HelloWorld.py所在的目录下;2.给该文件的目录写完整。
Solution 1:切换到HelloWorld.py所在的目录下
C:\Users\lenovo>f:
F:\>cd learning\python test
F:\learning\python test>python HelloWorld.py
得到的结果如下:

ps: cd 的意思是“切换目录”。
疑问:为什么不能在第一行“C:\Users\lenovo>”处直接切换到F盘, 例如:C:\Users\lenovo>f:\learning\pythontest 或者 C:\Users\lenovo>cd f:\learning\pythontest ? (此处已把“python test”文件夹中的空格符去掉了,见Solution 2) 如下图:

Solution2:给该文件的目录写完整
C:\Users\lenovo>python f:\learning\pythontest\HelloWorld.py
得到的结果如下:

注:此时文件夹的名字已由“python test”改为“pythontest”。
如果中间的空格不去掉,会得到如下结果:

so 为什么中间的空格会影响打印结果 ?
btw,如果不调用Python直接输入“HelloWorld.py”, 也能打印出正常结果,为什么这个不需要指明路径也能打印出结果来 ? 如下图所示。

Waiting for the coming training.
Mistakes in Hello World的更多相关文章
- 【转载学习前辈的经验】-- Mistakes I made (as a developer) 我(作为一名开发者)所犯过的错误
我 2006 年开始工作,至今已经 10 年.10 年是个里程碑,我开始回顾自己曾经犯过的错误,以及我希望从同行那里得到什么类型的忠告.一切都在快速改变,10 年了,我不能确定这些秘诀是否还有用. 不 ...
- 10 Biggest Business Mistakes That Every Entrepreneur Should Avoid
原文链接:http://www.huffingtonpost.com/syed-balkhi/10-biggest-business-mista_b_7626978.html When I start ...
- [转]50 Shades of Go: Traps, Gotchas, and Common Mistakes for New Golang Devs
http://devs.cloudimmunity.com/gotchas-and-common-mistakes-in-go-golang/ 50 Shades of Go: Traps, Gotc ...
- VK Cup 2015 - Round 2 (unofficial online mirror, Div. 1 only) E. Correcting Mistakes 水题
E. Correcting Mistakes Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset ...
- [TypeScript] 1. Catching JavaScript Mistakes with TypeScript
The TypeScript compiler is a powerful tool which catches mistakes even in vanilla JavaScript. Try it ...
- Top 10 Mistakes Java Developers Make--reference
This list summarizes the top 10 mistakes that Java developers frequently make. #1. Convert Array to ...
- HDOJ/HDU 1161 Eddy's mistakes(大写字母转换成小写字母)
Problem Description Eddy usually writes articles ,but he likes mixing the English letter uses, for e ...
- Yet Another 10 Common Mistakes Java Developers Make When Writing SQL (You Won’t BELIEVE the Last One)--reference
(Sorry for that click-bait heading. Couldn’t resist ;-) ) We’re on a mission. To teach you SQL. But ...
- 5 Common Interview Mistakes that Could Cost You Your Dream Job (and How to Avoid Them)--ref
There have been many articles on our site on software testing interviews. That is because, we, as IT ...
- hdu1161Eddy's mistakes
Problem Description Eddy usually writes articles ,but he likes mixing the English letter uses, for e ...
随机推荐
- lock锁速记
1.Lock关键字主要实现锁互斥,确保一个线程A在请求此操作时不会被其线程B请求中断(假设A先请求并在没有未完成的操作情况下申请了此互斥锁).lock的参数必须是基于引用类型的对象,不要是基本类型像b ...
- 利用reverse索引优化like语句的方法详解
在有一些情况下,开发同学经常使用like去实现一些业务需求,当使用like时,我们都知道使用like 前%(like '%111')这种情况是无法使用索引的,那么如何优化此类的SQL呢,下面是一个案例 ...
- 如何修改maven默认仓库(即repository)的路径
如何修改maven默认仓库(即repository)的路径 1 在maven的安装目录下,修改Eclipse(或IntelliJ IDEA)的MAVEN的存储位置,点击Browser按钮,选择set ...
- Caused by: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'name': was expecting ('true', 'false' or 'null')
Caused by: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'name': was expecting ( ...
- JAVA提高二十:CopyOnWriteArrayList&CopyOnWriteArraySet&ConcurrentHashMap介绍
前面我们将java集合类的大部分类都进行了深入分析,但我们会发现一个共性问题就是并发的问题,那么如何解决呢?我们前面基本都是通过Collections的一个工具类来进行的解决,但实际大部分使用中人们普 ...
- 《JavaScript语言精粹》【PDF】下载
<JavaScript语言精粹>[PDF]下载链接: https://u253469.pipipan.com/fs/253469-230382204 内容简介 javascript曾是&q ...
- 历史命令~/.bash_history,查看所有别名alias,命令执行顺序,命令行常用快捷键,输入输出重定向,wc统计字节单词行数
历史命令大小:/etc/profile中字段HISTSIZE=1000 历史命令保存文件:~/.bash_history history -c 清空历史命令 history -w 把历史命令写入~/. ...
- ABP .Net Core Entity Framework迁移使用MySql数据库
一.迁移说明 ABP模板项目Entity Framework Core默认使用的是Sql Server,也很容易将数据库迁移到MySQL,步骤如下. 二.迁移MySQL步骤 1. 下载项目 请到 ht ...
- Java中的集合概述
Java中的集合类有两个重要的分支,分别是接口Collection(包括List,Set等)和接口Map. 由于HashSet的内部实现原理使用了HashMap,所以我们先来了解Map集合类. 1.H ...
- tp3.2 事务处理
事务的机制通常被概括为“ACID”原则即原子性(A).稳定性(C).隔离性(I)和持久性(D). 原子性:构成事务的的所有操作必须是一个逻辑单元,要么全部执行,要么全部不执行. 稳定性:数据库在事 ...