all(25) -
UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xad in position 211: illegal multibyte sequence
#python Python Replace Space Char - Feb 14, 2025def _trim(s: str): return s.replace(' ', '').replace('.', '').strip() s.replace(' ', '')的确删除了句中的空格,但并没有把字符串末尾的空格删去,所以我不得不加了一个
#python Python Replace Space Char - Feb 14, 2025python包或模块的全局代码会在导入时自动运行。比如,包中的类、函数或者任何变量在导入时都会被初始
#python Python String Format - Sep 26, 2024f-strings (Python 3.6+) name = "Alice" age = 30 formatted_string = f"My name is {name} and I am {age} years old." str.format() name = "Bob" age = 25 formatted_string = "My name is {} and I am {} years old.".format(name, age) Percent % formatting name = "Charlie" age = 22 formatted_string = "My name is %s and I am %d years old.
#python Python Types - Sep 25, 2024Collection Data Types get length: len(dict) List list = [10, 20, 30] Lists are used to store multiple items in a single variable. ordered changeable allow duplicate values Tuple Set Dictionary dict = { "a": "abc", "year": 1986 } not allow duplicate values - Dictionaries cannot have two items with the same key.
#python Python Virtual Environment - Sep 25, 2024因为有时候需要不同的python的版本来运行程序,所以就出现了版本管理器pyenv,类似于nodej