示例#1
0
def func_use():  #module的使用import

    [x1, x2] = resolve(1, 6, 9)
    print("*********")
    print(x1)
    print(x2)
    [x3, x4] = resolve()
    print(x3)
    print(x4)
    [x5, x6] = resolve(0, 1, 2)
    print(x5)
    print(x6)
    print("*********")

    #func2 ????????????è???
    lst = [1, 2, 3]
    print("single value is in")
    result = func2(1, 2, 3)
    print(result)
    print("list is in")
    result = func2(*lst)
    print(result)
# -*- coding: utf-8 -*-

import module1 as md
md.func1()
md.func2()
md.func3()
md.func4()
md.func5()

import sys
print(sys.builtin_module_names)

hap2 = lambda num1,num2:num1+num2
print(hap2(10,20))
#lambda 매개변수 : 수식 으로, 함수화를 간단히 만들 수 있다. 

hap3 = lambda num1 = 10, num2=20:num1+num2
print(hap3())
print(hap3(300,400))
#초기 매개변수에 값자체를 넣어줄 수도있고, 람다함수를 호출하면서 값을 넣어줄수도있다.

mylist = [1,2,3,4,5]
add10 = lambda num : num+10

mylist = list(map(add10, mylist))
mylist

#lambda를 활용해 리스트에 값을 매칭할 수도 있다. 

mylist = list(map(lambda num : num +10, mylist))
示例#3
0
import module1

module1.func1()
module1.func2()
module1.func3()
示例#4
0
#function which are used frequently in many file....we can store them in a separate file and import that file when that functions are needed
import module1
import random

module1.func1()
module1.func2()
x=random.randrange(1,100)
print(x)
示例#5
0
文件: module1_a.py 项目: w51w/python
def main():
    module1.func1()
    module1.func2()
    module1.func3()
示例#6
0
from module1 import func1, func2, func3

func1()
func2()
func3()