Python酷库之旅-第三方库Pandas(064)

news2024/9/21 22:37:32

目录

一、用法精讲

251、pandas.Series.tz_localize方法

251-1、语法

251-2、参数

251-3、功能

251-4、返回值

251-5、说明

251-6、用法

251-6-1、数据准备

251-6-2、代码示例

251-6-3、结果输出

252、pandas.Series.at_time方法

252-1、语法

252-2、参数

252-3、功能

252-4、返回值

252-5、说明

252-6、用法

252-6-1、数据准备

252-6-2、代码示例

252-6-3、结果输出

253、pandas.Series.between_time方法

253-1、语法

253-2、参数

253-3、功能

253-4、返回值

253-5、说明

253-6、用法

253-6-1、数据准备

253-6-2、代码示例

253-6-3、结果输出

254、pandas.Series.str方法

254-1、语法

254-2、参数

254-3、功能

254-3-1、转换大小写

254-3-2、字符串匹配和搜索

254-3-3、字符串替换和去除

254-3-4、字符串分割和连接

254-3-5、提取和访问子串

254-3-6、格式化和填充

254-3-7、长度和计数

254-4、返回值

254-5、说明

254-6、用法

254-6-1、数据准备

254-6-2、代码示例

254-6-3、结果输出

255、pandas.Series.cat方法

255-1、语法

255-2、参数

255-3、功能

255-4、返回值

255-5、说明

255-6、用法

255-6-1、数据准备

255-6-2、代码示例

255-6-3、结果输出

二、推荐阅读

1、Python筑基之旅

2、Python函数之旅

3、Python算法之旅

4、Python魔法之旅

5、博客个人主页

一、用法精讲

251、pandas.Series.tz_localize方法
251-1、语法
# 251、pandas.Series.tz_localize方法
pandas.Series.tz_localize(tz, axis=0, level=None, copy=None, ambiguous='raise', nonexistent='raise')
Localize tz-naive index of a Series or DataFrame to target time zone.

This operation localizes the Index. To localize the values in a timezone-naive Series, use Series.dt.tz_localize().

Parameters:
tzstr or tzinfo or None
Time zone to localize. Passing None will remove the time zone information and preserve local time.

axis{0 or ‘index’, 1 or ‘columns’}, default 0
The axis to localize

levelint, str, default None
If axis ia a MultiIndex, localize a specific level. Otherwise must be None.

copybool, default True
Also make a copy of the underlying data.

Note

The copy keyword will change behavior in pandas 3.0. Copy-on-Write will be enabled by default, which means that all methods with a copy keyword will use a lazy copy mechanism to defer the copy and ignore the copy keyword. The copy keyword will be removed in a future version of pandas.

You can already get the future behavior and improvements through enabling copy on write pd.options.mode.copy_on_write = True

ambiguous‘infer’, bool-ndarray, ‘NaT’, default ‘raise’
When clocks moved backward due to DST, ambiguous times may arise. For example in Central European Time (UTC+01), when going from 03:00 DST to 02:00 non-DST, 02:30:00 local time occurs both at 00:30:00 UTC and at 01:30:00 UTC. In such a situation, the ambiguous parameter dictates how ambiguous times should be handled.

‘infer’ will attempt to infer fall dst-transition hours based on order

bool-ndarray where True signifies a DST time, False designates a non-DST time (note that this flag is only applicable for ambiguous times)

‘NaT’ will return NaT where there are ambiguous times

‘raise’ will raise an AmbiguousTimeError if there are ambiguous times.

nonexistentstr, default ‘raise’
A nonexistent time does not exist in a particular timezone where clocks moved forward due to DST. Valid values are:

‘shift_forward’ will shift the nonexistent time forward to the closest existing time

‘shift_backward’ will shift the nonexistent time backward to the closest existing time

‘NaT’ will return NaT where there are nonexistent times

timedelta objects will shift nonexistent times by the timedelta

‘raise’ will raise an NonExistentTimeError if there are nonexistent times.

Returns:
Series/DataFrame
Same type as the input.

Raises:
TypeError
If the TimeSeries is tz-aware and tz is not None.
251-2、参数

251-2-1、tz(必须)字符串或pytz.timezone对象,指定要本地化的时区,可以是时区的名称(如'US/Eastern')或一个pytz时区对象。

251-2-2、axis(可选,默认值为0)整数或字符串,指定沿着哪个轴进行本地化,对于Series,这个参数通常被忽略,因为Series只有一个轴,即轴0。

251-2-3、level(可选,默认值为None)整数或字符串,当处理多级索引(MultiIndex)时,此参数指定要本地化的级别,对普通的Series对象通常不需要使用。

251-2-4、copy(可选,默认值为None)布尔值,如果设置为False,会尝试在原地修改Series;如果为True,则会返回一个新的Series;默认值为None时,会自动选择合适的策略。

251-2-5、ambiguous(可选,默认值为'raise')字符串,处理夏令时切换期间的模糊时间,如果设置为'raise',则在出现模糊时间时抛出异常;如果设置为'NaT',则将这些时间标记为NaT(Not a Time);如果设置为'ignore',则保持原样。

251-2-6、nonexistent(可选,默认值为'raise')字符串,处理由于时区转换而不存在的时间,如果设置为'raise',则在出现不存在的时间时抛出异常;如果设置为'NaT',则将这些时间标记为NaT(Not a Time);如果设置为'shift',则将这些时间移到最近的存在时间。

251-3、功能

        用于将一个没有时区的Series对象的时间戳本地化到指定的时区。

251-4、返回值

        返回一个新的Series对象,其中时间戳已经被本地化到指定的时区,如果copy=False,可能会修改原始Series对象(具体取决于是否需要复制),新Series的时间戳将带有时区信息,格式为DatetimeIndex。

251-5、说明

        无

251-6、用法
251-6-1、数据准备
251-6-2、代码示例
# 251、pandas.Series.tz_localize方法
import pandas as pd
s = pd.Series(range(7),
              index=pd.DatetimeIndex(['2024-8-2 01:30:00',
                                      '2024-8-2 02:00:00',
                                      '2024-8-2 02:30:00',
                                      '2024-8-2 03:00:00',
                                      '2024-8-2 03:30:00',
                                      '2024-8-2 04:00:00',
                                      '2024-8-2 04:30:00']))
data = s.tz_localize('CET', ambiguous='infer')
print(data)
251-6-3、结果输出
# 251、pandas.Series.tz_localize方法
# 2024-08-02 01:30:00+02:00    0
# 2024-08-02 02:00:00+02:00    1
# 2024-08-02 02:30:00+02:00    2
# 2024-08-02 03:00:00+02:00    3
# 2024-08-02 03:30:00+02:00    4
# 2024-08-02 04:00:00+02:00    5
# 2024-08-02 04:30:00+02:00    6
# dtype: int64
252、pandas.Series.at_time方法
252-1、语法
# 252、pandas.Series.at_time方法
pandas.Series.at_time(time, asof=False, axis=None)
Select values at particular time of day (e.g., 9:30AM).

Parameters:
time
datetime.time or str
The values to select.

axis
{0 or ‘index’, 1 or ‘columns’}, default 0
For Series this parameter is unused and defaults to 0.

Returns:
Series or DataFrame
Raises:
TypeError
If the index is not a DatetimeIndex
252-2、参数

252-2-1、time(必须)字符串或datetime.time,指定要提取的时间,这个时间应当是datetime.time对象或符合时间格式的字符串(如'06:18')。

252-2-2、asof(可选,默认值为False)布尔值,如果设置为True,方法将返回在指定时间点之前最近的时间;如果为False,则方法仅返回与指定时间完全匹配的时间点的数据。

252-2-3、axis(可选,默认值为None)整数或字符串,指定沿着哪个轴进行操作,在Series中,通常可以忽略这个参数,因为Series只有一个轴(即轴0)。

252-3、功能

        用于从Series中筛选出指定时间点的数据,该方法将时间与Series的索引进行匹配,提取出符合指定时间的数据行,可以用来获取一天中某个特定时间点的数据,忽略具体的日期信息。

252-4、返回值

        返回一个新的Series对象,其中包含了在指定时间点的数据,返回的Series中的索引是与指定时间匹配的时间戳。

252-5、说明

        无

252-6、用法
252-6-1、数据准备
252-6-2、代码示例
# 252、pandas.Series.at_time方法
import pandas as pd
# 创建一个时间序列
idx = pd.date_range('2024-01-01', periods=4, freq='h')
data = pd.Series([1, 2, 3, 4], index=idx)
# 提取每天的'02:00'数据
result = data.at_time('02:00')
print("提取的时间点数据:")
print(result)
252-6-3、结果输出
# 252、pandas.Series.at_time方法
# 提取的时间点数据:
# 2024-01-01 02:00:00    3
# Freq: h, dtype: int64
253、pandas.Series.between_time方法
253-1、语法
# 253、pandas.Series.between_time方法
pandas.Series.between_time(start_time, end_time, inclusive='both', axis=None)
Select values between particular times of the day (e.g., 9:00-9:30 AM).

By setting start_time to be later than end_time, you can get the times that are not between the two times.

Parameters:
start_time
datetime.time or str
Initial time as a time filter limit.

end_time
datetime.time or str
End time as a time filter limit.

inclusive
{“both”, “neither”, “left”, “right”}, default “both”
Include boundaries; whether to set each bound as closed or open.

axis
{0 or ‘index’, 1 or ‘columns’}, default 0
Determine range time on index or columns value. For Series this parameter is unused and defaults to 0.

Returns:
Series or DataFrame
Data from the original object filtered to the specified dates range.

Raises:
TypeError
If the index is not a DatetimeIndex
253-2、参数

253-2-1、start_time(必须)字符串或datetime.time,指定时间范围的开始时间,应当是datetime.time对象或符合时间格式的字符串(如'06:18')。

253-2-2、end_time(必须)字符串或datetime.time,指定时间范围的结束时间,应当是datetime.time对象或符合时间格式的字符串(如'17:30')。

253-2-3、inclusive(可选,默认值为'both'){'both','neither','left','right'},指定时间范围的边界条件,可以选择以下四个值:

  • 'both':包括开始时间和结束时间。
  • 'neither':不包括开始时间和结束时间。
  • 'left':包括开始时间,但不包括结束时间。
  • 'right':不包括开始时间,但包括结束时间。

253-2-4、axis(可选,默认值为None)整数或字符串,指定沿着哪个轴进行操作,在Series中,通常可以忽略这个参数,因为Series只有一个轴(即轴0)。

253-3、功能

        用于从Series中筛选出在指定时间范围内的数据,它将时间与Series的索引进行匹配,提取出在开始时间和结束时间之间的数据,该方法可以用来获取一天中某个时间段的数据,忽略日期信息。

253-4、返回值

        返回一个新的Series对象,其中包含了在指定时间范围内的数据,返回的Series中的索引是与指定时间范围匹配的时间戳。

253-5、说明

        无

253-6、用法
253-6-1、数据准备
253-6-2、代码示例
# 253、pandas.Series.between_time方法
import pandas as pd
# 创建一个时间序列
idx = pd.date_range('2024-08-01', periods=24, freq='h')
data = pd.Series(range(24), index=idx)
# 提取每天的'09:00'到'17:00'之间的数据
result = data.between_time('09:00', '17:00')
print("提取的时间范围数据:")
print(result)
253-6-3、结果输出
# 253、pandas.Series.between_time方法
# 提取的时间范围数据:
# 2024-08-01 09:00:00     9
# 2024-08-01 10:00:00    10
# 2024-08-01 11:00:00    11
# 2024-08-01 12:00:00    12
# 2024-08-01 13:00:00    13
# 2024-08-01 14:00:00    14
# 2024-08-01 15:00:00    15
# 2024-08-01 16:00:00    16
# 2024-08-01 17:00:00    17
# Freq: h, dtype: int64
254、pandas.Series.str方法
254-1、语法
# 254、pandas.Series.str方法
pandas.Series.str()
Vectorized string functions for Series and Index.

NAs stay NA unless handled otherwise by a particular method. Patterned after Python’s string methods, with some inspiration from R’s stringr package.
254-2、参数

        无

254-3、功能
254-3-1、转换大小写

254-3-1-1、str.lower()将每个字符串转换为小写。

254-3-1-2、str.upper():将每个字符串转换为大写。

254-3-2、字符串匹配和搜索

254-3-2-1、str.contains(pattern)检查每个字符串是否包含指定的模式,返回布尔值的 Series。

254-3-2-2、str.startswith(prefix)检查每个字符串是否以指定的前缀开头,返回布尔值的 Series。

254-3-2-3、str.endswith(suffix)检查每个字符串是否以指定的后缀结尾,返回布尔值的 Series。

254-3-3、字符串替换和去除

254-3-3-1、str.replace(old,new)将每个字符串中的指定内容替换为新的内容。

254-3-3-2、str.strip()去除每个字符串的前后空白字符。

254-3-4、字符串分割和连接

254-3-4-1、str.split(separator)按照指定分隔符将字符串分割为列表。

254-3-4-2、str.join(sep)使用指定的分隔符连接列表中的元素。

254-3-5、提取和访问子串

254-3-5-1、str.extract(pattern)使用正则表达式提取匹配的子字符串。

254-3-5-2、str.get(i)获取每个字符串的第i个字符。

254-3-6、格式化和填充

254-3-6-1、str.pad(width,side='left',fillchar='')使用指定字符填充字符串,使其达到指定宽度。可以选择在左、右或两侧填充。

254-3-6-2、str.zfill(width)在左侧填充零,使字符串达到指定宽度。

254-3-7、长度和计数

254-3-7-1、str.len()返回每个字符串的长度。

254-3-7-2、str.count(pattern)计算每个字符串中匹配模式的出现次数。

254-4、返回值

        功能不同,产生了不同的返回值。

254-5、说明

        无

254-6、用法
254-6-1、数据准备
254-6-2、代码示例
# 254、pandas.Series.str方法
# 254-1、转换大小写
# 254-1-1、str.lower():将每个字符串转换为小写
import pandas as pd
s = pd.Series(['Hello', 'World', 'Pandas'])
s_lower = s.str.lower()
print(s_lower, end='\n\n')

# 254-1-2、str.upper():将每个字符串转换为大写
import pandas as pd
s = pd.Series(['Hello', 'World', 'Pandas'])
s_upper = s.str.upper()
print(s_upper, end='\n\n')

# 254-2、字符串匹配和搜索
# 254-2-1、str.contains(pattern):检查每个字符串是否包含指定的模式,返回布尔值的Series
import pandas as pd
s = pd.Series(['Hello', 'World', 'Pandas'])
s_contains = s.str.contains('o')
print(s_contains, end='\n\n')

# 254-2-2、str.startswith(prefix):检查每个字符串是否以指定的前缀开头,返回布尔值的Series
import pandas as pd
s = pd.Series(['Hello', 'World', 'Pandas'])
s_startswith = s.str.startswith('P')
print(s_startswith, end='\n\n')

# 254-2-3、str.endswith(suffix):检查每个字符串是否以指定的后缀结尾,返回布尔值的Series
import pandas as pd
s = pd.Series(['Hello', 'World', 'Pandas'])
s_endswith = s.str.endswith('s')
print(s_endswith, end='\n\n')

# 254-3、字符串替换和去除
# 254-3-1、str.replace(old, new):将每个字符串中的指定内容替换为新的内容
import pandas as pd
s = pd.Series(['Hello', 'World', 'Pandas'])
s_replace = s.str.replace('o', '0')
print(s_replace, end='\n\n')

# 254-3-2、str.strip():去除每个字符串的前后空白字符
import pandas as pd
s_with_spaces = pd.Series(['  Hello  ', ' World ', ' Pandas '])
s_strip = s_with_spaces.str.strip()
print(s_strip, end='\n\n')

# 254-4、字符串分割和连接
# 254-4-1、str.split(separator):按照指定分隔符将字符串分割为列表
import pandas as pd
s = pd.Series(['Hello', 'World', 'Pandas'])
s_split = s.str.split('l')
print(s_split, end='\n\n')

# 254-4-2、str.join(sep):使用指定的分隔符连接列表中的元素
import pandas as pd
s_join = pd.Series([['a', 'b', 'c'], ['d', 'e'], ['f']])
s_joined = s_join.str.join('-')
print(s_joined, end='\n\n')

# 254-5、提取和访问子串
# 254-5-1、str.extract(pattern):使用正则表达式提取匹配的子字符串
import pandas as pd
s_dates = pd.Series(['2022-08-01', '2023-07-06', '2024-08-03'])
s_extract = s_dates.str.extract(r'(\d{4})-(\d{2})-(\d{2})')
print(s_extract, end='\n\n')

# 254-5-2、str.get(i):获取每个字符串的第i个字符
import pandas as pd
s = pd.Series(['Hello', 'World', 'Pandas'])
s_get = s.str.get(1)
print(s_get, end='\n\n')

# 254-6、格式化和填充
# 254-6-1、str.pad(width, side='left', fillchar=' '):使用指定字符填充字符串,使其达到指定宽度。可以选择在左、右或两侧填充
import pandas as pd
s = pd.Series(['Hello', 'World', 'Pandas'])
s_pad = s.str.pad(10, side='right', fillchar='*')
print(s_pad, end='\n\n')

# 254-6-2、str.zfill(width):在左侧填充零,使字符串达到指定宽度
import pandas as pd
s = pd.Series(['Hello', 'World', 'Pandas'])
s_zfill = s.str.zfill(10)
print(s_zfill, end='\n\n')

# 254-7、长度和计数
# 254-7-1、str.len():返回每个字符串的长度
import pandas as pd
s = pd.Series(['Hello', 'World', 'Pandas'])
s_len = s.str.len()
print(s_len, end='\n\n')

# 254-7-2、str.count(pattern):计算每个字符串中匹配模式的出现次数
import pandas as pd
s = pd.Series(['Hello', 'World', 'Pandas'])
s_count = s.str.count('l')
print(s_count, end='\n\n')

# 254-8、综合案例
import pandas as pd
# 创建一个包含混合文本数据的Series
data = pd.Series(['  Myelsa  ', 'bob123', 'C@r0l', 'DAVID'])
# 清洗和标准化文本数据
cleaned_data = data.str.strip().str.lower().str.replace(r'\d+', '').str.replace(r'[^a-z]', '')
print(cleaned_data)
254-6-3、结果输出
# 254、pandas.Series.str方法
# 254-1、转换大小写
# 254-1-1、str.lower():将每个字符串转换为小写
# 0     hello
# 1     world
# 2    pandas
# dtype: object

# 254-1-2、str.upper():将每个字符串转换为大写
# 0     HELLO
# 1     WORLD
# 2    PANDAS
# dtype: object

# 254-2、字符串匹配和搜索
# 254-2-1、str.contains(pattern):检查每个字符串是否包含指定的模式,返回布尔值的Series
# 0     True
# 1     True
# 2    False
# dtype: bool

# 254-2-2、str.startswith(prefix):检查每个字符串是否以指定的前缀开头,返回布尔值的Series
# 0    False
# 1    False
# 2     True
# dtype: bool

# 254-2-3、str.endswith(suffix):检查每个字符串是否以指定的后缀结尾,返回布尔值的Series
# 0    False
# 1    False
# 2     True
# dtype: bool

# 254-3、字符串替换和去除
# 254-3-1、str.replace(old, new):将每个字符串中的指定内容替换为新的内容
# 0     Hell0
# 1     W0rld
# 2    Pandas
# dtype: object

# 254-3-2、str.strip():去除每个字符串的前后空白字符
# 0     Hello
# 1     World
# 2    Pandas
# dtype: object

# 254-4、字符串分割和连接
# 254-4-1、str.split(separator):按照指定分隔符将字符串分割为列表
# 0    [He, , o]
# 1     [Wor, d]
# 2     [Pandas]
# dtype: object

# 254-4-2、str.join(sep):使用指定的分隔符连接列表中的元素
# 0    a-b-c
# 1      d-e
# 2        f
# dtype: object

# 254-5、提取和访问子串
# 254-5-1、str.extract(pattern):
#       0   1   2
# 0  2022  08  01
# 1  2023  07  06
# 2  2024  08  03

# 254-5-2、str.get(i):获取每个字符串的第i个字符
# 0    e
# 1    o
# 2    a
# dtype: object

# 254-6、格式化和填充
# 254-6-1、str.pad(width, side='left', fillchar=' '):使用指定字符填充字符串,使其达到指定宽度。可以选择在左、右或两侧填充
# 0    Hello*****
# 1    World*****
# 2    Pandas****
# dtype: object

# 254-6-2、str.zfill(width):在左侧填充零,使字符串达到指定宽度
# 0    00000Hello
# 1    00000World
# 2    0000Pandas
# dtype: object

# 254-7、长度和计数
# 254-7-1、str.len():返回每个字符串的长度
# 0    5
# 1    5
# 2    6
# dtype: int64

# 254-7-2、str.count(pattern):计算每个字符串中匹配模式的出现次数
# 0    2
# 1    1
# 2    0
# dtype: int64

# 254-8、综合案例
# 0    myelsa
# 1    bob123
# 2     c@r0l
# 3     david
# dtype: object
255、pandas.Series.cat方法
255-1、语法
# 255、pandas.Series.cat方法
pandas.Series.cat()
Accessor object for categorical properties of the Series values.

Parameters:
data
Series or CategoricalIndex
255-2、参数

        无

255-3、功能

        提供了对类别数据的创建、修改、重命名和管理等功能,使得处理数据时可以利用类别数据的特性进行更加细致的操作和分析。

255-4、返回值

        返回值是一个Categorical对象,它提供了关于类别数据的详细信息,包括类别的列表、类别的顺序(如果有的话)等,该对象使得对类别数据的进一步操作和分析更加灵活和高效。

255-5、说明

        无

255-6、用法
255-6-1、数据准备
255-6-2、代码示例
# 255、pandas.Series.cat方法
import pandas as pd
# 创建一个包含类别数据的 Series
data = pd.Series(['apple', 'banana', 'apple', 'orange', 'banana'], dtype='category')
# 输出原始数据及其类别
print("Original Series:")
print(data)
print("Categories:")
print(data.cat.categories, end='\n\n')

# 255-1、设置类别的顺序
data = data.cat.set_categories(['banana', 'apple', 'orange'], ordered=True)
print("Ordered Categories:")
print(data.cat.categories, end='\n\n')

# 255-2、 添加新类别
data = data.cat.add_categories(['grape'])
print("Categories after Adding 'grape':")
print(data.cat.categories, end='\n\n')

# 255-3、 删除类别
data = data.cat.remove_categories(['orange'])
print("Categories after Removing 'orange':")
print(data.cat.categories, end='\n\n')

# 255-4、 重命名类别
data = data.cat.rename_categories({'banana': 'yellow_banana', 'apple': 'green_apple'})
print("Categories after Renaming:")
print(data.cat.categories, end='\n\n')

# 255-5、 获取类别的整数编码
print("Integer Encoding of the Series:")
print(data.cat.codes, end='\n\n')

# 255-6、查看数据和类别编码
print("Data with Integer Encoding:")
print(data)
255-6-3、结果输出
# 255、pandas.Series.cat方法
# Original Series:
# 0     apple
# 1    banana
# 2     apple
# 3    orange
# 4    banana
# dtype: category
# Categories (3, object): ['apple', 'banana', 'orange']
# Categories:
# Index(['apple', 'banana', 'orange'], dtype='object')

# 255-1、设置类别的顺序
# Ordered Categories:
# Index(['banana', 'apple', 'orange'], dtype='object')

# 255-2、 添加新类别
# Categories after Adding 'grape':
# Index(['banana', 'apple', 'orange', 'grape'], dtype='object')

# 255-3、 删除类别
# Categories after Removing 'orange':
# Index(['banana', 'apple', 'grape'], dtype='object')

# 255-4、 重命名类别
# Categories after Renaming:
# Index(['yellow_banana', 'green_apple', 'grape'], dtype='object')

# 255-5、 获取类别的整数编码
# Integer Encoding of the Series:
# 0    1
# 1    0
# 2    1
# 3   -1
# 4    0
# dtype: int8

# 255-6、查看数据和类别编码
# Data with Integer Encoding:
# 0      green_apple
# 1    yellow_banana
# 2      green_apple
# 3              NaN
# 4    yellow_banana
# dtype: category
# Categories (3, object): ['yellow_banana' < 'green_apple' < 'grape']

二、推荐阅读

1、Python筑基之旅
2、Python函数之旅
3、Python算法之旅
4、Python魔法之旅
5、博客个人主页

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1977228.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【java】单行注释(//)与多选注释(/* */)

文章目录 单行注释多行注释注意事项 在Java中&#xff0c;注释是用来给代码添加说明的&#xff0c;它不会被编译器执行。Java提供了两种主要的注释方式&#xff1a;单行注释和多行注释&#xff08;有时也称为块注释或块级注释&#xff09;。 单行注释 单行注释以两个正斜杠&…

爬小红book--自定义获取

免责声明:本文仅做分享!!! from DrissionPage import ChromiumPage import time pa str(input("输入关键词&#xff1a;")) pl str(input("输入评论内容&#xff1a;")) page ChromiumPage() page.get(https://www.xiaohongshu.com/search_result?keyw…

php生成xml文件的封装类文件-可生成带缩进格式化的xml文件及关于opcache缓存的操作小工具cachetool的使用

一、php生成xml文件的封装类文件-可生成带缩进格式化的xml文件 最近因为有需要&#xff0c;对生成xml文件进行了一些处理&#xff0c;很早之前使用过SimpleXML加载接口返回的xml数据并处理&#xff0c;这次的使用偏向于XML文件的生成。有一个需求&#xff0c;生成的xml文件格式…

【保姆级讲解下AI绘画自动生成器有哪些?】

&#x1f3a5;博主&#xff1a;程序员不想YY啊 &#x1f4ab;CSDN优质创作者&#xff0c;CSDN实力新星&#xff0c;CSDN博客专家 &#x1f917;点赞&#x1f388;收藏⭐再看&#x1f4ab;养成习惯 ✨希望本文对您有所裨益&#xff0c;如有不足之处&#xff0c;欢迎在评论区提出…

CICD流水线

一、CICD流水线简介 CICD概念 CI/CD流水线是现代软件开发的一个核心概念&#xff0c;它涉及自动化和管理软件从开发到部署的整个生命周期 概念定义 具体有三点&#xff1a;持续集成、持续交付、持续部署 流水线组成为&#xff1a;代码提交、测试、构建、部署、结果通知 二…

营销型豆浆机料理机网站模板/EyouCMS营销型类企业模板

营销型豆浆机料理机网站模板&#xff0c;EyouCMS营销型类企业模板。模板自带eyoucms内核&#xff0c;无需再下载eyou系统&#xff0c;原创设计、手工书写DIVCSS&#xff0c;完美兼容IE7、Firefox、Chrome、360浏览器等&#xff1b;主流浏览器&#xff1b;结构容易优化&#xff…

雨量气象站:实时、准确地监测并记录降水情况

在自然界的水循环中&#xff0c;雨&#xff0c;作为天空与大地的信使&#xff0c;不仅滋养了万物&#xff0c;也影响着人类社会的方方面面。为了更准确地监测和预测降水情况&#xff0c;雨量气象站应运而生&#xff0c;成为了现代气象观测体系中重要的一环。 雨量气象站&#x…

FFmpeg源码:av_reduce函数分析

AVRational结构体和其相关的函数分析&#xff1a; FFmpeg有理数相关的源码&#xff1a;AVRational结构体和其相关的函数分析 FFmpeg源码&#xff1a;av_reduce函数分析 一、av_reduce函数的声明 av_reduce函数声明在FFmpeg源码&#xff08;本文演示用的FFmpeg源码版本为7.0…

P10477 题解

题目传送门 题目传送门&#xff08;洛谷&#xff09; Step1 理解题意 一共有 T T T 组数据有一个地铁&#xff0c;有一个中心车站&#xff08;即为根&#xff09;&#xff0c;有一个人从中心车站出发。对于每组数据&#xff0c;给定两个同样长度的01串 s 1 s_1 s1​ , s …

五、MYSQL企业常用架构与调优经验理论篇

&#x1f33b;&#x1f33b; 目录 一、选择 PerconaServer、MariaDB 还是 MYSQL二、常用的 MYSQL 调优策略三、MYSOL 常见的应用架构分享四、MYSOL 经典应用架构 注&#xff1a;全是理论干货&#xff0c;没有实战&#xff0c;想看实战的绕路哦&#xff01;&#xff01;&#xf…

ScriptEcho:AI赋能的前端代码生成神器

ScriptEcho&#xff1a;AI赋能的前端代码生成神器 在前端开发中&#xff0c;如果你总是觉得写代码太费时费力&#xff0c;那么 ScriptEcho 将成为你的救星。这个 AI 代码生成平台不仅能帮你省下大量时间&#xff0c;还能让你轻松愉快地写出生产级代码。本文将带你了解 ScriptEc…

Java中spring boot validation 自定义注解使用

创建一个注解 Target({ElementType.FIELD})//需要写注解的三三个要素 Retention(RUNTIME) Documented Constraint(validatedBy {IsSystemYesNoVaildation.class})//绑定 在这里会报错 你需要去实现 public interface IsSystemYesNo {String message() default "数据字典&…

【Python实战】如何优雅地实现文字 二维码检测?

前几篇&#xff0c;和大家分享了如何通过 Python 和相关库&#xff0c;自动化处理 PDF 文档&#xff0c;提高办公效率。 【Python实战】自动化处理 PDF 文档&#xff0c;完美实现 WPS 会员功能【Python实战】如何优雅地实现 PDF 去水印&#xff1f;【Python实战】一键生成 PDF…

自媒体新闻资讯类网站模板/EyouCMS自媒体资讯类网站模板

自媒体新闻资讯类网站模板&#xff0c;EyouCMS自媒体资讯类网站模板。模板自带eyoucms内核&#xff0c;无需再下载eyou系统&#xff0c;原创设计、手工书写DIVCSS&#xff0c;完美兼容IE7、Firefox、Chrome、360浏览器等&#xff1b;主流浏览器&#xff1b;结构容易优化&#x…

U460909 [BCSP小高2024T4]先序遍历/小羊的晚餐 题解

Part.1 有关本题 本蒟蒻想起这道巧妙 又毒瘤 的题&#xff0c;到处搜寻提交窗口。好不容易找到窗口&#xff0c;有花了 3 h 3h 3h 的时间调题。 本蒟蒻为了悲剧不再发生&#xff0c;于是出了这道题&#xff0c;有写下了这篇题解以供后人。 以下的题解默认以阅读过原题。 P…

数学建模--禁忌搜索

目录 算法基本原理 关键要素 应用实例 实现细节 python代码示例 总结 禁忌搜索算法在解决哪些具体类型的组合优化问题中最有效&#xff1f; 禁忌搜索算法的邻域结构设计有哪些最佳实践或案例研究&#xff1f; 如何动态更新禁忌表以提高禁忌搜索算法的效率和性能&#…

FPGA开发——数码管数字时钟的设计

一、概述 数码管数字时钟的基本原理是通过内部的计时电路&#xff08;如晶振、分频器、计数器等&#xff09;产生一个稳定的时钟信号&#xff0c;该信号经过处理后被转换为小时、分钟和秒的时间信息。这些信息随后被发送到数码管显示模块&#xff0c;通过控制数码管中不同LED段…

Android读取拨号记录功能

Android读取拨号记录功能 Android读取拨号记录功能 首先会检测应用是否有读取拨号记录的权限 MainActivity.java public class MainActivity extends AppCompatActivity {private ListView listCalls;private List<Map<String, Object>> mapList;private static f…

有界,可积,存在原函数和连续的关系

目录 1.可积和有界的关系 2.连续和可积的关系 3.连续和存在原函数的关系 4.可积和存在原函数没有关系 1.可积和有界的关系 可积必有界&#xff0c;有界不一定可积&#xff0c;反例可以举狄利克雷函数 2.连续和可积的关系 f(x)连续&#xff0c;则一定可积&#xff0c;可积不…

Mac安装nvm以及配置环境变量

安装nvm brew install nvm安装成功后会出现这样一段话: Add the following to your shell profile e.g. ~/.profile or ~/.zshrc:export NVM_DIR"$HOME/.nvm"[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh&q…