Python基础

 我是观看廖雪峰的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''里面的内容是默认不转义   , ‘’‘ ’‘’ 用于多字符需要换行)

多敲代码 视频与文档配合学习 希望自己能坚持下去 加油 小白!!!

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值