爬虫日志第一篇

入门嘛,选了本(简明Python教程)a-byte-of-python,应该是很入门的了,不过对于我这个菜鸡,还是遇到了困难,安装pyther,安装不成功,后来下载了个dll文件和DX修复器,解决,也折腾了几次,翻译好多英文,花了点时间,配置好环境后,开始正式学习,写的第一个程序当然是:hello world,文件夹打错了字,竟然折腾了好一会,才发现,⊙﹏⊙‖∣,接着是:

age = 20
name = 'Swaroop'
print('{0} was {1} years old when he wrote this book'.format(name, age))

print('Why is {0} playing with that python?'.format(name))

这个代码也看了好一会,才看懂。

name + 'is' +str(age) + 'years old'

这个还没懂,不过没关系,这个只是作者举的反面例子。

后来是折腾这个:

# 对于浮点数 '0.333' 保留小数点(.)后三位
print('{0:.3f}'.format(1.0/3))
# 使用下划线填充文本,并保持文字处于中间位置
# 使用 (^) 定义 '___hello___'字符串长度为 11
print('{0:_^11}'.format('hello'))
# 基于关键词输出 'Swaroop wrote A Byte of Python'
print('{name} wrote {book}'.format(name='Swaroop', book='A Byte of Python'))
输出:
0.333
___hello___

Swaroop wrote A Byte of Python

终于应该看懂了。

格式,还是不太清楚,不过,

1、0是一个代号而已,(:)是解释这个(.3f)只保留3个Floats,后面这个format(1.0/3)),本来没看懂,后来尝试发现format(1/3)也可以。

下面两个比较简单。

学到这里,效率好慢,明天休息,打算折腾一天,为自己加油!!

你可能感兴趣的:(爬虫日志)