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 ...
随机推荐
- Python爬虫Scrapy(二)_入门案例
本章将从案例开始介绍python scrapy框架,更多内容请参考:python学习指南 入门案例 学习目标 创建一个Scrapy项目 定义提取的结构化数据(Item) 编写爬取网站的Spider并提 ...
- json api
from flask import Flask, redirect, url_for, jsonify, request app = Flask(__name__) users = [] ''' RE ...
- 50、html补充
今天补充几个html标签 <body>内常用标签 1.<div>和<span> <div></div> : <div>只是一个块 ...
- JMeter脚本java代码String数组要写成String[] args,不能写成String args[],否则报错。
JMeter脚本java代码String数组中括号要写在类型关键字后面,不能写在变量名后面.
- 数据分析与展示——Matplotlib库入门
Matplotlib库入门 Matplotlib库介绍 Matliotlib库是Python优秀的数据可视化第三方库. Matliotlib库的效果见:http://matplotlib.org/ga ...
- xml文件解析(使用解析器)
一.Xml解析,解析xml并封装到list中的javabean中 OM是用与平台和语言无关的方式表示XML文档的官方W3C标准.DOM是以层次结构组织的节点或信息片断的集合.这个层次结构允许开发人员在 ...
- Java 集成 速卖通开发.
一.申请成为开发者 申请入口:http://isvhz.aliexpress.com/isv/index.htm 说明文档:http://activities.aliexpress.com/open/ ...
- Git安装和使用(谨记)
刚开始用git的小白适用,,转自http://www.cnblogs.com/qijunjun/p/7137207.html 实际项目开发中,我们经常会用一些版本控制器来托管自己的代码,今天就来总结下 ...
- UVALive 3716 DNA Regions
题目大意:给定两个长度相等的字符串A和B,与一个百分比p%,求最长的.失配不超过p%的区间长度.O(nlogn). 题目比较简单套路,推推式子就好了. 记S[i]表示到下标i一共有多少个失配,就相当于 ...
- ES6 let和const命令(3)
const 用来声明常量.一旦声明,就不能改变. const在声明必须初始化,只声明不赋值会出错 const的作用域与let一样,只在声明的块级作用域有效. const命令声明的常量也不提升,同样存在 ...