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 ...
随机推荐
- Spring Boot整合 JdbcTemplate
(1) 在pom.xml加入jdbcTemplate的依赖: (2) 编写DemoDao类,声明为:@Repository,引入JdbcTemplate (3) 编写DemoService类,引入De ...
- this的理解
this的理解 看了阮一峰的this讲解,下面是我的理解: 总结来说 this指向 调用this所在方法 的对象: 普通函数 例子1 function test(){ this.x = 1; cons ...
- cocoapods管理以及常遇到的问题
CocoaPods使用 安装成功啦,咱们来创建Podfile文件 //咱们先滚去项目的根目录,如果不会,你就先滚去看看shell命令教程吧 $ cd /Users/JamesGu/Desktop/Co ...
- [array] leetcode-55. Jump Game - Medium
leetcode-55. Jump Game - Medium descrition Given an array of non-negative integers, you are initiall ...
- qt调用simsimi api实现小黄鸡
项目地址:https://github.com/racaljk/xiaojianji 好吧我把它命名为小贱鸡.,下面说一说他的实现. 由于官方的simsimi api需要收费,免费试用版有各种限制,所 ...
- Pytorch windows10安装教程
强烈建议安装anaconda之后再来安装这个pytorch,具体怎么安装百度搜索就知道了. 温馨提示,在安装anaconda的时候记得将"添加到环境变量"(安装的时候是英文的)这一 ...
- bzoj 3718: [PA2014]Parking
Description 你的老板命令你将停车场里的车移动成他想要的样子. 停车场是一个长条矩形,宽度为w.我们以其左下角顶点为原点,坐标轴平行于矩形的边,建立直角坐标系.停车场很长,我们可以认为它一直 ...
- Thinkphp开启调试模式
3.0版本的调试模式开启,必须在项目入口文件中添加常量APP_DEBUG定义,如下: define('APP_DEBUG',True); // 开启调试模式 开启调试模式后,你可能感觉不到什么变化,不 ...
- 设计模式之 - 代理模式(Proxy Pattern)
代理模式:代理是一种常用的设计模式,其目的就是为其他对象提供一个代理以控制对某个对象的访问.代理类负责为委托类预处理消息,过滤消息并转发消息,以及进行消息被委托类执行后的后续处理.很多可以框架中都有用 ...
- Lucene分词停用词库stopwords
! " $ % & ' ( ) * + , - -- . .. ... ...... ................... ./ .一 .数 .日 / // 0 1 2 3 4 5 ...