python系统学习日记 L1~L2

文章内容是根据笨办法学python课程中的代码修改为适合python3的代码
书中练习一和练习二 py2和py3的区别主要在于print函数
在Python2和Python3中都提供print()方法来打印信息,但两个版本间的print稍微有差异
主要体现在以下几个方面:
1.python3中print是一个内置函数,有多个参数,而python2中print是一个语法结构;
2.Python2打印时可以不加括号:print ‘hello world’, Python3则需要加括号 print(“hello world”)

L1:第一个程序
书中代码改为

print("Hello World !")
print("Hello Again ")
print("I like typing this.")
print("This is fun.")
print("Yay! Printing.")
print("I'd much rather you 'not'.")
print('I "said" do not touch this. ')

输出部分的结果为:
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.

L2:注释和井号"#"

# A comment, this is so you can your program later
# Anything after the # is ignored by python

print("I could have code like this .")  # and the comment atfer is ignored

# You cant also use a comment to "disable" or comment out a piece of code:
# print "This won't run."

print("This will run.")

输出部分的结果为:
I could have code like this .
This will run.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值