>>>import numpy as np
>>> a = np.arange(15).reshape(3,5)>>> a
array([[0,1,2,3,4],[5,6,7,8,9],[10,11,12,13,14]])>>> a.shape
(3,5)>>> a.ndim
2>>> a.dtype.name
'int64'>>> a.itemsize
8>>> a.size
15>>>type(a)<class'numpy.ndarray'>>>> b = np.array([6,7,8])>>> b
array([6,7,8])>>>type(b)<class'numpy.ndarray'>
import pendulum
now = pendulum.now("Europe/Paris")# Changing timezone
now.in_timezone("America/Toronto")# Default support for common datetime formats
now.to_iso8601_string()# Shifting
now.add(days=2)
from PIL
import Image
#Open image using Image module
im = Image.open("images/cuba.jpg")#Show actual Image
im.show()#Show rotated Image
im = im.rotate(45)
im.show()
from skimage.filters
import gaussian_filter
from moviepy.editor
import VideoFileClip
defblur(image):""" Returns a blurred (radius=2 pixels) version of the image """return gaussian_filter(image.astype(float), sigma=2)
clip = VideoFileClip("my_video.mp4")
clip_blurred = clip.fl_image( blur )
clip_blurred.write_videofile("blurred_video.mp4")
Requests Python程序包(座右铭:“ HTTP for Humans”)通过自动执行许多繁琐的任务来解决此问题,让发送HTTP请求变得异常简单。它消除了添加查询字符串或执行POST表单编码的需要。它还可以使与HTTP服务器的连接自动保持活动状态,从而无需编写大量代码。
import requests
from requests.exceptions
import HTTPError
for url in['https://api.github.com','https://api.github.com/invalid']:try:response = requests.get(url)# If the response was successful, no Exception will be raised
response.raise_for_status()except HTTPError as http_err:print(f'HTTP error occurred: {http_err}')# Python 3.6 except Exception as err:print(f'Other error occurred: {err}')# Python 3.6 else:print('Success!')
In [5]: dates = pd.date_range("20130101", periods=6)
In [6]: dates
Out[6]:
DatetimeIndex(['2013-01-01','2013-01-02','2013-01-03','2013-01-04','2013-01-05','2013-01-06'],
dtype='datetime64[ns]', freq='D')
In [7]: df = pd.DataFrame(np.random.randn(6,4), index=dates, columns=list("ABCD"))
In [8]: df
Out[8]:A B C D
2013-01-010.469112-0.282863-1.509059-1.1356322013-01-021.212112-0.1732150.119209-1.0442362013-01-03-0.861849-2.104569-0.4949291.0718042013-01-040.721555-0.706771-1.0395750.2718602013-01-05-0.4249720.5670200.276232-1.0874012013-01-06-0.6736900.113648-1.4784270.524988
import win32com.client as win32
excel = win32.gencache.EnsureDispatch('Excel.Application')
excel.Visible = True_ =input("Press ENTER to quit:")
excel.Application.Quit()
以下是使用 Python 接入京东价格信息比价 API 的一般指南: 寻找合适的比价 API 服务: 市面上有一些第三方数据服务提供商提供京东比价 API。这些服务通常需要你注册账号并申请 API Key 和 API Secret 等凭证,以便进行接口调用。你可以根据自己…
大纲 题目地址内容 解题代码地址 题目
地址
https://leetcode.com/problems/happy-number/description/
内容
Write an algorithm to determine if a number n is happy.
A happy number is a number defined by the following process:
Starting with any positive inte…
一、rust代码
将json文件写入到 excel中。(保持json :key原始顺序)
use indexmap::IndexMap;
use serde::Deserialize;
use serde_json::{Value, from_str};
use std::error::Error;
use std::io::{self, Write};
use std::path::{Path};
u…