这里写自定义目录标题
笨办法学python3-----01
报错以及更改记录
用Windows Powershell在文件目录中打开,报错:
PS C:\Users\Master\7> python ex1.py
File "ex1.py", line 1
print "Hello World!"
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Hello World!")?
报错原因:这是Python2的格式。python3是需要加括号,记得切换英文括号!
PS C:\Users\Master\7> python ex1.py
Hello World!
Hello Again
I like typing this.
This is fun.
Yay! Printing.
I'd much rather you 'not'.
I "said" do not touch this.
PS C:\Users\Master\7> python ex1.py
Hello World!
Hello Again
I like typing this.
This is fun.
Yay! Printing.
I'd much rather you 'not'.
练习
1.让你的脚本再打印出一行。
2.让你的脚本只打印一行。
3.在任一行的开头放一个 # ,看看会发生什么?试着弄明白这个符号的作用。
1让你的脚本再打印出一行。
(…\n)
PS C:\Users\Master\7> python ex1.py
Hello World!
Hello Again
I like typing this.
This is fun.
Yay! Printing.
I'd much rather you 'not'.
I "said" do not touch this.
2.让你的脚本只打印一行
(…,end="")
PS C:\Users\Master\7> python ex1.py
Hello World!
Hello AgainI like typing this.This is fun.Yay! Printing.I'd much rather you 'not'.I "said" do not touch this.
3.在任一行的开头放一个 # ,看看会发生什么?试着弄明白这个符号的作用。
#解释用
PS C:\Users\Master\7> python ex1.py
Hello World!
Hello AgainI like typing this.This is fun.Yay! Printing.I'd much rather you 'not'.