English documents:
-
-
vars
([
object])
-
-
-
-
Return the
__dict__
attribute for a module, class, instance, or any other object with a
__dict__
attribute.
-
-
Objects such as modules and instances have a updateable
__dict__
attribute; however, other Objects could have write restrict Ions on their
__dict__
attributes (for example, classes use a dictproxy to prevent direct dictionary updates).
-
-
Without an argument,
vars()
acts
locals()
. Note, the locals dictionary is only useful for reads since updates to the locals dictionary is ignored.
-
Description
1. When a function does not receive a parameter, its function, like the locals function, returns a local variable within the current scope.
#functions without parameters As with locals functions>>> V1 =VARs ()>>> L1 =locals ()>>>v1{'__name__':'__main__','__builtins__': <module'Builtins'(built-inch);'v1': {...},'L1': {...},'__spec__': None,'__doc__': None,'__package__': None,'__loader__': <class '_frozen_importlib. Builtinimporter'>}>>>l1{'__name__':'__main__','__builtins__': <module'Builtins'(built-inch);'v1': {...},'L1': {...},'__spec__': None,'__doc__': None,'__package__': None,'__loader__': <class '_frozen_importlib. Builtinimporter'}
2. When a function receives a parameter, the parameter can be a module, class, class instance, or an object that defines the __dict__ property.
#Acting on Modules>>>Import Time>>>VARs (time) {'gmtime': <built-inchfunction Gmtime>'Tzname': ('? D1ú±êx?ê±??','? D1ú?? Á?ê±'),'TimeZone':-28800,'Struct_time': <class 'Time.struct_time','CTime': <built-inchfunction Ctime>'Perf_counter': <built-inchfunction Perf_counter>'Mktime': <built-inchfunction Mktime>'localtime': <built-inchfunction Localtime>' Time': <built-inchfunction Time>'__package__':"','Altzone':-32400,'Clock': <built-inchfunction Clock>'Strptime': <built-inchfunction Strptime>'monotonic': <built-inchfunction Monotonic>'__loader__': <class '_frozen_importlib. Builtinimporter','Get_clock_info': <built-inchfunction Get_clock_info>'Sleep': <built-inchfunction Sleep>'Process_time': <built-inchfunction Process_time>'__name__':' Time','_struct_tm_items': 9,'__spec__': Modulespec (name=' Time', loader=<class '_frozen_importlib. Builtinimporter', origin='built-in'),'__doc__': " This module provides various functions to manipulate time values.\n\nthere is the standard representations of time. One is the number\nof seconds since the Epoch, in UTC (a.k.a. GMT). Integer\nor a floating point number (to represent fractions of seconds). \nthe Epoch is system-defined; On Unix, it's generally January 1st, 1970.\nthe actual value can be retrieved by calling Gmtime (0). \n\nthe other Represen Tation is a tuple of 9 integers giving local time.\nthe tuple items are:\n year (including century, e.g. 1998) \ n Month ( 1-12) \ n Day (1-31) \ hours (0-23) \ minutes (0-59) \ seconds (0-59) \ Weekday (0-6, Monday is 0) \ n Julian Day n the year, 1-366) \ n DST (daylight Savings time) flag ( -1, 0 or 1) \nif the DST flag is 0, the time was given in the Regula R time Zone;\nif It is 1, the time was given in the DST time zone;\nif it is-1, mktime () should guess based on the date an D Time.\n\nvariables:\n\ntimezone--difference in seconds between UTC and local StandaRd Time\naltzone--difference in seconds between UTC and local DST time\ndaylight--whether local time should reflect D St\ntzname--tuple of (Standard time zone name, DST time zone name) \n\nfunctions:\n\ntime ()--return current time in SEC Onds since the Epoch as a float\nclock ()--return CPU time since process start as a float\nsleep ()--delay for a number of seconds given as a float\ngmtime ()--convert seconds since Epoch to UTC tuple\nlocaltime ()--Convert seconds since Ep och to local time tuple\nasctime ()--convert time tuple to String\nctime ()--convert time in seconds to String\nmktime () --Convert local time tuple to seconds since Epoch\nstrftime ()--Convert time tuple to string according to format SPECIF Ication\nstrptime ()--parse string to time, tuple according to format specification\ntzset ()--The local timezone','strftime': <built-inchfunction Strftime>'Asctime': <built-inchfunction Asctime>'Daylight': 0}#acting on a class>>>VARs (Slice) mappingproxy ({'__ne__': <slot Wrapper'__ne__'Of'Slice'Objects>,'__getattribute__': <slot Wrapper'__getattribute__'Of'Slice'Objects>,'__reduce__': <method'__reduce__'Of'Slice'Objects>,'Start': <member'Start'Of'Slice'Objects>,'Indices': <method'Indices'Of'Slice'Objects>,'__ge__': <slot Wrapper'__ge__'Of'Slice'Objects>,'Stop': <member'Stop'Of'Slice'Objects>,'__eq__': <slot Wrapper'__eq__'Of'Slice'Objects>,'Step': <member'Step'Of'Slice'Objects>,'__hash__': None,'__doc__':'Slice (stop) \nslice (start, stop[, step]) \n\ncreate a slice object. This is used for extended slicing (e.g. a[0:10:2]).','__repr__': <slot Wrapper'__repr__'Of'Slice'Objects>,'__le__': <slot Wrapper'__le__'Of'Slice'Objects>,'__gt__': <slot Wrapper'__gt__'Of'Slice'Objects>,'__new__': <built-inchMethod__new__of type object at 0x6a91b420>'__lt__': <slot Wrapper'__lt__'Of'Slice'Objects>})#acting on a class instance>>>classA (object):Pass>>> A.__dict__{}>>>VARs (a) {}>>> A.name ='Kim'>>> A.__dict__{'name':'Kim'}>>>VARs (a) {'name':'Kim'}
Python built-in function (--vars)