机器学习03

import os

a = 100


def calc(a, b, fun1):
    c = fun1(a, b)

    return c


def a_dd(a, b):

    return a + b


print(calc(10, 3, a_dd))

# 参数函数

nums = [1, 2, 3, 5]

print(dir(nums))

# 列出所有属性和方法

print(globals())
# 函数内部定义函数


def outer():

    def inter():
        print('hello inter 2')

    print('hello outer 1')
    # return inter()


# outer()
outer()
# 计算代码执行时间
# -----------------
# import time
# from random import randint
# from math import *
# import numpy as np
# as 别名
#
# ------------------
'''
os 模块

'''

print(os.name)
print(os.sep)
# 分隔符
print(os.path.abspath('train02.py'))

print(os.path.isfile('train02.py'))
print(os.path.splitext('train02.py'))
# 取文件名和后缀名
# 类


class Student(object):

    def __init__(self,name , age, heigh):
        # __init__ 方法里,以参数形式定义特征,我们称之为属性
        self.name = name
        self.age = age
        self.heigh = heigh

    # 方法

    @staticmethod
    def run():
        print('跑步')


s1 = Student('gll', 24, 183)
print(s1.name)
print(s1.age)

s1.run()
#!/usr/bin/env python# coding: utf-8
class Student:    
    def __init__(self, name, score):        
        self.name = name        
        self.score = score
 student = Student("Hugh", 99)
print(student.score)


from mxnet import nd

x = nd.arange(12)
print(x)

X = x.reshape(4, 3)

print(X)
print(x.shape)
##(12,)  一行12列
print(x.size)
print(X.size)
print(X.shape)

猜你喜欢

转载自blog.csdn.net/weixin_41865104/article/details/115095214