摘要:
%下面是lambda的示例,它包含三个参数并添加前两个参数。1 my_function = lambda a, b, c : a + b 2 my_function(1, 2, 3) 3 1 my_list = [] 2 for number in range(0, 1000): 3 if numb 阅读全文
摘要:
1 class Person: 2 department = 'School of Information' #a class variable 3 4 def set_name(self, new_name): #a method 5 self.name = new_name 6 def set_ 阅读全文
摘要:
1 import datetime as dt 2 import time as tm %时间从纪元开始以秒为单位返回当前时间。(1970年1月1日)1 tm.time() 1520242063.03 1 dtnow = dt.datetime.fromtimestamp(tm.time()) 2 阅读全文
摘要:
Let's import our datafile mpg.csv, which contains fuel economy data for 234 cars. mpg : miles per gallon class : car classification cty : city mpg cyl 阅读全文
摘要:
1 print('Chris' + 2) TypeError Traceback (most recent call last) <ipython-input-37-82ccfdd3d5d3> in <module>() > 1 print('Chris' + 2) TypeError: must 阅读全文
摘要:
%解压序列到不同的变量中1 x = ('Christopher', 'Brooks', 'brooksch@umich.edu') 2 fname, lname, email = x 1 fname 'Christopher' 1 lname 'Brooks' %确保变量的数量和解压的值相同1 x = ('Christopher', 'Brooks', 'brooksch@umi... 阅读全文
摘要:
%字典用keys来连接values1 x = {'Christopher Brooks': 'brooksch@umich.edu', 'Bill Gates': 'billg@microsoft.com'} 2 x['Christopher Brooks'] # Retrieve a value 阅读全文
摘要:
list 阅读全文
摘要:
NoneType int float function 阅读全文
摘要:
tuple 阅读全文