我是观看廖雪峰的Python教程来学习的https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/001431658624177ea4f8fcb06bc4d0e8aab2fd7aa65dd95000 (廖雪峰老师的Python教程)
>>> classmates = ['Michael', 'Bob', 'Tracy']
>>> classmates
['Michael', 'Bob', 'Tracy']
>>> len(classmates)
3
>>> classmates[0]
'Michael'
>>> classmates[-2]
'Bob'
>>>
上面的程序是在shell里面完成的 ,一开始以为在PyCharm编辑器也是跟shell里面的程序一样,结果发现根本运行不出来结果
classmates = ['Michael', 'Bob', 'Tracy']
classmates
len(classmates)
classmates[0]
经同学指导后得知shell里面会自动返回值给你看的~一般检测用,然后pycharm还有其他编辑器都要print才会打印出来! 学到了
classmates = ['gogo', 'jerry', 'tony']
print(classmates)
print(len(classmates))
print(classmates[0])
# -*- coding: utf-8 -*- 作业 请打印出以下变量的值:
n = 123 f = 456.789
s1 = 'Hello, world'
s2 = 'Hello, \'Adam\''
s3 = r'Hello, "Bart"'
s4 = r'''Hello,
Lisa!'''
print('''
n = 123
f = 456.789
s1 = \'hello , world\'
s2 = \'hello , \\'adam\\'\'
s3 = r\'hello,"bart"\'
s4 = r\'"hellp, \nlisa!\'''')
# s4 = r\'''Hello, \nLisa!''\' (r''里面的内容是默认不转义 , ‘’‘ ’‘’ 用于多字符需要换行)
多敲代码 视频与文档配合学习 希望自己能坚持下去 加油 小白!!!