current position:Home>8 practical Python skills that are easy to use and don't have to suffer a loss for half a year
8 practical Python skills that are easy to use and don't have to suffer a loss for half a year
2022-02-02 02:51:00 【jiejie】
Hello everyone , I'm Jay As a data worker , We use it every day Python Handle most of the work . In the process , We will continue to learn some useful skills and tricks .
ad locum , I tried to A - Z Share some of these tips in the beginning format , And these methods are briefly introduced in this paper , If you are interested in one or more of them , You can check the official documents through the references at the end of the article . I hope it can help you .
all or any
Python One of the many reasons why languages are so popular , Because it has good readability and expressiveness .
People often joke that Python yes Executable pseudocode
. When you can write code like this , It's hard to refute .
x = [True, True, False]
if any(x):
print(" At least one True")
if all(x):
print(" Is full of True")
if any(x) and not all(x):
print(" At least one True And a False")
Copy code
bashplotlib
Have you ever thought about drawing graphics in the console ?
Bashplotlib It's a Python library , He can help us on the command line ( A rough environment ) Draw data in .
# Module installation
pip install bashplotlib
# Draw examples
import numpy as np
from bashplotlib.histpgram import plot_hist
arr = np.ramdom.normal(size=1000, loc=0, scale=1)
plot_hist(arr, bincount=50)
Copy code
collections
Python There are some great default data types , But sometimes their behavior doesn't exactly meet your expectations .
Fortunately, ,Python The standard library provides collections modular [1]. This convenient add-on provides you with more data types .
from collections import OrderedDict, Counter
# Remember the order in which keys are added !
x = OrderedDict(a=1, b=2, c=3)
# Count the frequency of each character
y = Counter("Hello World!")
Copy code
dir
Have you ever thought about how to check Python Object and see what properties it has ? Enter... On the command line :
dir()
dir("Hello World")
dir(dir)
Copy code
emoji
emoji[3] It is a visual emotional symbol used in wireless communication in Japan , Drawing refers to drawing , Words refer to characters , Can be used to represent a variety of expressions , A smiling face means a smile 、 Cake means food, etc . On Chinese mainland ,emoji Is often called “ Little yellow face ”, Or call it emoji.
# Install the module
pip install emoji
# Make a try
from emoji import emojize
print(emojize(":thumbs_up:"))
Copy code
from future import
Python One of the results of popularity , There are always new versions under development . The new version means new features —— Unless your version is out of date .
But don't worry . Use this __future__ modular [4] Can help you use Python Future version import function . Literally , It's like time travel 、 Magic or something
from __future__ import print_function
print("Hello World!")
Copy code
geogy
Geography , This is a challenging area for most programmers . When getting geographic information or drawing maps , There will be many problems . This geopy modular [5] Make geography related content very easy .
pip install geopy
Copy code
It abstracts a series of different geocoding services API Come to work . Through it , You can get the full street address of a place 、 latitude 、 Longitude and even altitude .
There is also a useful distance class . It calculates the distance between two positions in your preferred unit of measurement .
from geopy import GoogleV3
place = "221b Baker Street, London"
location = GoogleV3().geocode(place)
print(location.address)
print(location.location)
Copy code
howdoi
When you use terminal When programming the terminal , By having a problem in StackOverflow Search for answers on , After that, it will return to the terminal to continue programming , Sometimes you don't remember the solution you found before , You need to review StackOverflow, But I don't want to leave the terminal , Then you need to use this useful command line tool howdoi[6].
pip install howdoi
Copy code
Whatever problems you have , You can ask it , It will try its best to reply .
howdoi vertical align css
howdoi for loop in java
howdoi undo commits in git
Copy code
But please pay attention to —— It will be from StackOverflow Grab the code from the best answer . It may not always provide the most useful information ......
howdoi exit vim
Copy code
copyright notice
author[jiejie],Please bring the original link to reprint, thank you.
https://en.pythonmana.com/2022/02/202202020250589682.html
The sidebar is recommended
- How IOS developers learn Python Programming 22 - Supplement 1
- Python can meet any API you need
- Python 3 process control statement
- The 20th of 120 Python crawlers, 1637. All the way business opportunity network joined in data collection
- Datetime of pandas time series preamble
- How to send payslips in Python
- [Python] closure and scope
- Application of Python Matplotlib color
- leetcode 1627. Graph Connectivity With Threshold (python)
- Python thread 08 uses queues to transform the transfer scenario
guess what you like
-
Python: simple single player strange game (text)
-
Daily python, chapter 27, Django template
-
TCP / UDP communication based on Python socket
-
Use of pandas timestamp index
-
leetcode 148. Sort List(python)
-
Confucius old book network data collection, take one anti three learning crawler, python crawler 120 cases, the 21st case
-
[HTB] cap (datagram analysis, setuid capability: Python)
-
How IOS developers learn Python Programming 23 - Supplement 2
-
How to automatically identify n + 1 queries in Django applications (2)?
-
Data analysis starts from scratch. Pandas reads HTML pages + data processing and analysis
Random recommended
- 1313. Unzip the coding list (Java / C / C + + / Python / go / trust)
- Python Office - Python edit word
- Collect it quickly so that you can use the 30 Python tips for taking off
- Strange Python strip
- Python crawler actual combat, pyecharts module, python realizes China Metro data visualization
- DOM breakpoint of Python crawler reverse
- Django admin custom field stores links in the database after uploading files to the cloud
- Who has powder? Just climb who! If he has too much powder, climb him! Python multi-threaded collection of 260000 + fan data
- Python Matplotlib drawing streamline diagram
- The game comprehensively "invades" life: Python releases the "cool run +" plan!
- Python crawler notes: use proxy to prevent local IP from being blocked
- Python batch PPT to picture, PDF to picture, word to picture script
- Advanced face detection: use Dlib, opencv and python to detect face markers
- "Python 3 web crawler development practice (Second Edition)" is finally here!!!!
- Python and Bloom filters
- Python - singleton pattern of software design pattern
- Lazy listening network, audio novel category data collection, multi-threaded fast mining cases, 23 of 120 Python crawlers
- Troubleshooting ideas and summary of Django connecting redis cluster
- Python interface automation test framework (tools) -- interface test tool requests
- Implementation of Morse cipher translator using Python program
- [Python] numpy notes
- 24 useful Python tips
- Pandas table beauty skills
- Python tiktok character video, CV2 module, Python implementation
- I used Python to climb my wechat friends. They are like this
- 20000 words take you into the python crawler requests library, the most complete in history!!
- Answer 2: why can you delete the table but not update the data with the same Python code
- [pandas learning notes 02] - advanced usage of data processing
- How to implement association rule algorithm? Python code and powerbi visualization are explained to you in detail (Part 2 - actual combat)
- Python adds list element append() method, extend() method and insert() method [details]
- python wsgi
- Introduction to Python gunicorn
- Python dictionary query key value pair methods and examples
- Opencv Python reads video, processes and saves it frame by frame
- Python learning process and bug
- Imitate the up master and realize a live broadcast room controlled by barrage with Python!
- Essence! Configuration skills of 12 pandas
- [Python automated operation and maintenance road] path inventory
- Daily automatic health punch in (Python + Tencent cloud server)
- [Python] variables, comments, basic data types