Python note (1) on whether we should continue learning python

  • 2020-04-02 09:36:02
  • OfStack

You used to be asked in interviews, are you familiar with Linux? I'm always embarrassed to say, "well... Know something about it.

However, when I graduated from college, I didn't even have a Linux virtual machine installed, let alone the system. Although I do know that this system can be operated entirely by command. Later work, sometimes write some code, SVN submitted, the server is Linux, he is running on Windows client. I remember a project that required a shell to launch a Java program. Do you know what I did at that time? Take their shell, ask them where they want to change, and change the path to the Java class you want to launch. Okay, no way to understand it. At the end of another interview, I had to confess that I didn't know much about Linux commands.

One might say: Linux commands are not difficult. Just take a few days. Now I would say that to a friend who doesn't know Linux at all. But if I don't take the first step in learning commands. I will have to be embarrassed again in the interview for a long time to come.
Back to the point, should we learn something that doesn't seem useful right now but is actually good?
My answer: if you do have the resources and are willing to invest in yourself, I think so.
1. This extra study will make your weekend more fulfilling.
2, when learning to a certain degree, will have a new view of things.
3. You have an extra chip when it comes to the interview.
4. There's a theory: the more you learn, the more you know you don't know. The more you know, the bigger the world you see!

As the love song goes: "we always forgot to go to a bridge, to each other's heart to look", I wonder if we also forgot to go to a bridge, to look somewhere else! Ha ha

So let's go into PYTHON!

Python notes (1)

About Python, if you want to learn, I suggest you check the website :(because I just decided to collect some spare time to learn it, the recommendation may not be the best)

(link: http://book.huihoo.com/dive-into-python/5.4_zh-cn/html/toc/index.html) the Dive to python"
(link: http://docs.python.org/)
(link: http://woodpecker.org.cn/)
(link: http://code.google.com/intl/zh-CN/edu/languages/google-python-class/introduction.html)

I think it's great to be new to python, because you can install HelloWorld right away!
Maybe we're way past the age of excitement. In fact, I mean python is definitely a language you can learn easily.

1, function declaration with def

 
def buildConnectionString(params): 


2. Import module: import

 
import odbchelper 


When importing a module, it is the python compiler that goes to the path of its own environment variable to find the module. If the module to be imported is under a custom path, the path must be put into the environment variable first.
 
import sys 
sys.path.append('/my/new/path') 

3, if_else statement (instead of '{}' in Java, python controls blocks of code by indentation.)
 
if n > 1: 
return n * fib(n - 1) 
else: 
print 'end of the line' 
return 1 

4. Built-in data type List:
List li = ["a", "b", "mpilgrim", "z", "example"]

Wrap it in [].

A. for var in list, you can iterate over A list. Don't try to add or remove elements while traversing.
 
squares = [1, 4, 9, 16] 
sum = 0 
for num in squares: 
sum += num 
print sum ## 30 

B. Use in to determine whether an element is in the list:
 
list = ['larry', 'curly', 'moe'] 
if 'curly' in list: 
print 'yay 

C. list's other methods:
 
list.append(elem) -- adds a single element to the end of the list. Common error: does not return the new list, just modifies the original. 
list.insert(index, elem) -- inserts the element at the given index, shifting elements to the right. 
list.extend(list2) adds the elements in list2 to the end of the list. Using + or += on a list is similar to using extend(). 
list.index(elem) -- searches for the given element from the start of the list and returns its index. Throws a ValueError if the element does not appear (use "in" to check without a ValueError). 
list.remove(elem) -- searches for the first instance of the given element and removes it (throws ValueError if not present) 
list.sort() -- sorts the list in place (does not return it). (The sorted() function shown below is preferred.) 
list.reverse() -- reverses the list in place (does not return it) 
list.pop(index) -- removes and returns the element at the given index. Returns the rightmost element if index is omitted (roughly the opposite of append()). 

D. other examples of lists:
 
 list = ['larry', 'curly', 'moe'] 
list.append('shemp') ## append elem at end 
list.insert(0, 'xxx') ## insert elem at index 0 
list.extend(['yyy', 'zzz']) ## add list of elems at end 
print list ## ['xxx', 'larry', 'curly', 'moe', 'shemp', 'yyy', 'zzz'] 
print list.index('curly') ## 2 

list.remove('curly') ## search and remove that element 
list.pop(1) ## removes and returns 'larry' 
print list ## ['xxx', 'moe', 'shemp', 'yyy', 'zzz'] 

The pure purpose of this article is to get more people to learn what they may refuse to learn for various reasons.
I hope you can be inspired by me, and have action oh!

Related articles: