Python's basic training Code

Code. 1:
# - * - Coding: UTF-. 8 - * -
DEF function (* Numbers):
SUM = 0
for NUM in Numbers:
SUM = SUM + NUM * NUM
return SUM


Print function (l, 2,3)
A = [7, 8]
Print function (A *)
Print function (* [1,2])
Print function (* (l, 2,3))

Code 2:
IF the __name__ == '__main__'
code appreciated how? ?

__name__ is the current name of the module, when the module is run directly when the module named __main__. What this means is that, when the module is executed directly, the following block of code will be executed when the module is introduced, the code block is not running.


Code. 3:
dt Import datetime AS

# is removed from the bag datetime dt class, then the class methods datetime now is
A = dt.datetime.now ()
Print A

# is removed from the bag datetime dt class initialization method then initializes datetime Object
D1 = dt.datetime (2005, 2, 16)
D2 = dt.datetime (2004, 12 is, 31 is)
Print (D1 - D2) .days

代码4:
import pandas as pd
import numpy as np

 

dates = pd.date_range('20130101',periods=6)

df = pd.DataFrame(np.random.randn(6,4),index=dates,columns=list('ABCD'))

print df

print 'extracted data:', df.at [dates [0], 'A']

print 'transposed \ n', df.T

Guess you like

Origin www.cnblogs.com/medik/p/11108645.html