笨办法学python_1

习题一

python2.7

1
2
3
4
5
6
7
8
# -*- coding: utf-8 -*-
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."

python3.7

1
2
3
4
5
6
7
8
# -*- coding: utf-8 -*-
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.")
# -*- coding: utf-8 -*-
这行用在脚本开头可以设定脚本编码格式

Tips:python 2.7与python 3.7的区别就是后者更加严格规范,必须带上括号!

python中使用(#)符号单行注释