Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use COPY and SYS

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you "how to use COPY and SYS". The content is simple and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn this article "how to use COPY and SYS".

1. Copyimport copy # copy and deepcopy compare a = [1, 2, 3, 4, ['await,' b']] # original object b = a # assignment, pass object reference c = copy.copy (a) # object copy, shallow copy d = copy.deepcopy (a) # object copy Deep copy a.append (5) # modify object a [4] .append ('c') # modify array object print'a =', a print'b =', b print'c =', c print d =', d output result: a = [1, 2, 3, 4, ['A','b','c'], 5] b = [1, 2, 3, 4 ['await,' baked,'c'], 5] c = [1, 2, 3, 4, ['ajar,' c']] d = [1, 2, 3, 4, ['averse,' b']] II, SYS

Argv: implements passing parameters from outside the program to the program.

Path: get a collection of strings that specify the search path for the module. You can put the written module under a given path and find it correctly when you import in the program.

Modules:sys.modules is a global dictionary that is loaded in memory after python is started. Whenever a programmer imports a new module, sys.modules automatically records the module. When the module is imported the second time, python will look it up directly in the dictionary, thus speeding up the running of the program. It has all the methods that a dictionary has.

The stdin, stdout, and stderr variables contain stream objects that correspond to the standard Imax O stream. If you need better control over output and print doesn't meet your requirements, they are what you need. You can also replace them, where you can redirect output and input to other devices (device), or handle them in a non-standard way

Platform: gets the current system platform.

Exit (status=None): exit in the middle of the program.

Getrefcount (): returns the number of calls to the object.

Getdefaultencoding (): gets the current code of the system, which generally defaults to ascii.

Getfilesystemencoding (): the encoding method is used to get the file system. Return 'return under mbcs',mac' utf-8'. under Windows

The above is all the contents of the article "how to use COPY and SYS". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report