Python还是很久之前用过,大约一年前吧,而且只是很简单的使用。现在时间比较充足,而且作为一个崇尚唯快不破的语言,我想要拾起来。
目前主要的参考是为中国电力出版社的《Python编程》(第四版)。
准备将代码都手工敲一遍。今天体验下IDLE下敲代码。以后书上所有的代码及运行结果我都会直接拷贝过来,备份。
Python 3.7.0b2 (tags/v3.7.0b2:b0ef5c979b, Feb 27 2018, 20:38:21)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> bob = ['Bob', 42, 30000, 'software']
>>> sue = ['sue', 45, 40000, 'hardware']
>>> bob[0],sue[2]
('Bob', 40000)
>>> bob[0] = 'Bob Smith'
>>> bob[0]
'Bob Smith'
>>> bob[0].split()[-1]
'Smith'
>>> sue[2] *=1.25
>>> sue
['sue', 45, 50000.0, 'hardware']
>>> people = [bob, sue]
>>> for person in people:
print(person)
['Bob Smith', 42, 30000, 'software']
['sue', 45, 50000.0, 'hardware']
>>> people[1][0]
'sue'
>>> people[1][0] = 'Sue Jones'
>>> pays = [person[2] for person in people]
>>> pays
[30000, 50000.0]
>>> pays2 = map((lambda x:x[2]), people)
>>> list(pays2)
[30000, 50000.0]
>>> sum(person[2] for person in people)
80000.0
>>> people.append(['Tom', 50, 0, None])
>>> len(people)
3
>>> NAME, AGE, PAY = range(3)
>>> bob = ['Bob Smith',42,10000]
>>> bob[NAME]
'Bob Smith'
>>>
没有任何提示的工具总是人感觉不爽,以后我会用vscode吧
坑:Python3.7,vscode是没有代码自动补全的。3.5以下有。
按了几个插件
vscode插件:python
pip install flake8
pip install yap