def lambda_handler(event, context): log.info("Starting lambda.") log.info("We are using boto3 version: " + boto3.__version__) log.info(m.greeting("leonard")) log.info(m2.strong_greeting("leonard")) log.info(str(os.listdir())) log.info("Ending lambda.") print(event) print(context.get_remaining_time_in_millis()) print(context.aws_request_id) if context.client_context: print(context.client_context) print(context.function_name) print(context.function_version) print(context.identity.cognito_identity_id) print(context.identity.cognito_identity_pool_id) print(context.invoked_function_arn) print(context.log('Log this for me please')) print(context.log_group_name) print(context.log_stream_name) print(context.memory_limit_in_mb) return 'It works!'
import module print(module.greeting("James"))
# My first script that loads another module import module #lets see what this module offers help(module) #do some work r = module.dowork(4,2) print(r) print( module.greeting('Marcus') )
x = self.a self.a += 1 return x else: raise StopIteration myclass = MyNumbers() myiter = iter(myclass) for x in myiter: print(x) #modulos: import module as x x.greeting("Saul") y = x.person["name"] print(y) #z = dir(x) #print(z) from module import person print(person["age"]) import datetime x = datetime.datetime.now() print(x.year, x.strftime("%A"), x.strftime("%B")) import math
#!/usr/bin/python3 # -*- coding: utf-8 -*- import module module.test() print(module.greeting('michael'))
import module module.greeting("Jonathan") a = module.person1["age"] print(a) #We can rename a module with as keyword import module as mx mx.greeting("Jonathan") a = mx.person1["age"] print(a) import platform x = dir(platform) print(x) ## We can only choose to take certain part from any module with from keyword. from module import person1
import module import math as m import datetime module.greeting("Aca") # module.ling() x = m.pi phi = "{:2f}".format(x) print(phi) y = m.sqrt(64) print(y) today = datetime.datetime.now() print(today)
# Day Fifty Two # Python Modules # Modules are collections of python code that are stored in an external file # the module can contain function definitions, variables etc # they allow you flexibility to share functionality between different programs # without having to copy the same code into each one # import # for module code to be available for use in another program you need to use the import statement # importing of modules is usually done at the beginning of a program import module # import our module # our function definitions can then be called with the syntax module_name.function_name module.greeting("Matt") # Welcome Matt module.age(28) # 28 huh? you're all grown up! module.profession("Doctor") # And a you're a Doctor # from import # from import can be used to import individual names from a module, or all names using "*" # functions imported like this can be called without using the module name prefix from module_two import * # import everything years_salary("£28,000") # Who makes £28,000 a year, Impressive! # when importing a module the interpreter will search for it in a certain order
import module module.greeting("Ara") # import module as m # m.greeting("Ara") import math as m x=m.pi print(x) y=m.sqrt(64) #akar kuadrat print(y) import datetime today=datetime.datetime.now() print(today)
import module module.greeting("keval")
# coding utf-8 import module print module.greeting("junbang")
return a + b @decoc def myfunction2(a, b,c): print(" myfunction2(%s,%s,%s) called." % (a, b,c)) return a + b+c print(myfunction1(1,2)) print(myfunction2(1,2,3)) #偏函数 import functools int2=functools.partial(int,base=2) print(int2('1000000')) #模块 import module print(module.greeting('wangdg')) from PIL import Image im=Image.open('E:\壁纸\sex1.jpeg') print(im.format, im.size, im.mode) im.thumbnail((200, 100)) im.save('thumb.png', 'png') #面向对象 class Person(object):#这里object只的是继承的类,如果没有继承默认写object __slots__ = ('name', 'age') #约束class只能定义的属性,这样实例就能动态添加属性 """docstring for Person""" def __init__(self, name,age): super(Person, self).__init__() self.name = name self.age=age
for x, y in thisdict.items(): print(x, y) print(len(thisdict)) thisdict["color"] = "red" print(thisdict) thisdict.pop("model") print(thisdict) # modules import module module.greeting("Sam") from module import person1 print (person1["age"]) # built in modules import platform x = platform.system() print(x) y = dir(platform) print(y)
import datetime import module # import module as m # from module import greeting print(module.greeting("Arif")) name = module.person['name'] print('\n' + name) print() x = datetime.datetime.now() # x = datetime.datetime(2020, 5, 17) print(x) print(x.year) print(type(x.year)) print(x.strftime("%A"))
import module import math as m import datetime module.greeting("Nafi") module.ling() x = m.pi # phi = "{:2f}".format(x) print(x) y = m.sqrt(64) print(y) today = datetime.datetime.now() print(today)
import module import platform module.greeting("Wyaat") a = module.person1["age"] print(a) a = module.person1["name"] print(a) x = platform.system() print(x) # x=dir(platform) # print(x)
import module as m from classess_and_objects import Person m.greeting("Jonathan") x = m.person1["name"] print(x) x = Person("James", 24) print(x.age) print(x.name)
import module print module.greeting('wlj') print module.greeting('wljwlj')
def testGreeting(self): self.assertEqual("Hello, John", module.greeting("John")) self.assertNotEqual("Hello, Jane", module.greeting("Jena"))
import module module.test() d = module.greeting('mike') print(d)
import module from module import person1 import datetime module.greeting("hoohoo") a = module.person1["country"] print(a) print(person1["name"]) x = datetime.datetime.now() print(x) print(x.year) print(x.strftime("%A"))
print("_____________________________") x = 500 def myfun(): global x x = 200 myfun() print(x) print("_____________________________") #L50 #call from another file import module module.greeting(" Asmaa") a = module.person1["age"] print(a) print("_____________________________") #L51 import module as mx a = mx.person1["name"] print(a) print("_____________________________") import platform x = platform.system() print(x) x = dir(platform) print(x) print("_____________________________") from module import person1