@fight4f · Post #8468 · 18.06.2024 г., 05:25
人類研究幾千年來 大部份人也是基因混血 國家/國籍 = 與基因血緣沒有關係 基因= 大部份人的基因也沒有100%純正 歷代祖先 = 很多今天的國家,在古代也不存在, 所以不要亂說自己祖先是那國及那種人。 膚色 = 人種頂多能分 : 黑人 白人 黄人 及中亞人 , 再細分也是一樣, 某國那國也只是國籍政治及文化圈劃分( 基因也是不純的) #Human
Hashtags
TGINSIGHT SIMILAR POSTS
Изворен канал @pythonotes · Post #65 · 8 апр.
Небольшой трик с регулярными выражениями который редко вижу в чужом коде. Допустим, вам нужно распарсить простой текст и вытащить оттуда пары имя+телефон. Вернуть всё это надо в виде списка словарей. Возьмем очень простой пример текста. >>> text = ''' >>> Alex:8999123456 >>> Mike:+799987654 >>> Oleg:+344456789 >>> ''' Соответственно, для выделения нужных элементов будем использовать группы. Получится такой паттерн: (\w+):([\d+]+) Как мы будем формировать словарь из найденных групп? >>> import re >>> results = [] >>> for match in re.finditer(r"(\w+):([\d+]+)", text): >>> results.append({ >>> "name": match.group(1), >>> "phone": match.group(2) >>> }) >>> print(results) [{'name': 'Alex', 'phone': '8999123456'}, ...] Можно немного сократить запись используя zip >>> results = [] >>> for match in re.finditer(r"(\w+):([\d+]+)", text): >>> results.append(dict(zip(['name', 'phone'], match.groups()))) Но есть способ лучше! Это именованные группы в regex. Можно в паттерне указать имя группы и результат сразу забрать в виде словаря. >>> for match in re.finditer(r"(?P<name>\w+):(?P<phone>[\d+]+)", text): >>> results.append(match.groupdict()) То есть всё что я сделал, это добавил в начале группы (внутри сбокочек) такую запись: (?P<group-name>...) Теперь найденная группа имеет имя и можно обратиться к ней как к элементу списка >>> name = match['name'] Либо забрать сразу весь словарь методом groupdict() >>> match.groupdict() #tricks#regex
Пребарај: #human
@fight4f · Post #8468 · 18.06.2024 г., 05:25
人類研究幾千年來 大部份人也是基因混血 國家/國籍 = 與基因血緣沒有關係 基因= 大部份人的基因也沒有100%純正 歷代祖先 = 很多今天的國家,在古代也不存在, 所以不要亂說自己祖先是那國及那種人。 膚色 = 人種頂多能分 : 黑人 白人 黄人 及中亞人 , 再細分也是一樣, 某國那國也只是國籍政治及文化圈劃分( 基因也是不純的) #Human
Hashtags
@everything_science · Post #3469 · 22.05.2025 г., 20:53
Deep voiced men tend to have a lower concentration of sperm in their ejaculation than men with higher pitched voices. #Human 🔔@Everything_Science
Hashtags
@everything_science · Post #3445 · 10.05.2025 г., 08:15
man from New Zealand named Nigel Richards won the French Scrabble championship without actually speaking French. #Human 🔔@Everything_Science
Hashtags
@everything_science · Post #3441 · 07.05.2025 г., 17:01
Former billionaire Chuck Feeney has given away over 99% of his $8 billion to help underprivileged kids go to college. By the time of his passing in October 2023, he was worth less than $2 million. #Human 🔔@Everything_Science
Hashtags
@everything_science · Post #3436 · 05.05.2025 г., 17:23
Steve Harvey sent a TV every year to the teacher who said he would never be on television. #Human 🔔@Everything_Science
Hashtags
@everything_science · Post #3433 · 04.05.2025 г., 06:38
This woman donated a kidney to her boss and then got fired for taking extended time to recover from the surgery. #Human 🔔@Everything_Science
Hashtags
@everything_science · Post #3430 · 02.05.2025 г., 10:00
When Messi heard a boy had been wearing his jersey made from a plastic bag, he sent the boy a real one signed by him. #Human 🔔@Everything_Science
Hashtags
@everything_science · Post #3422 · 30.04.2025 г., 05:18
A German man created a traffic jam on an empty street in Google Maps by wheeling around 99 smartphones. #Human 🔔@Everything_Science
Hashtags
@everything_science · Post #3407 · 22.04.2025 г., 16:51
Japanese man earns $80,000 per year by renting himself out as a friend to lonely people. #Human 🔔@Everything_Science
Hashtags
@everything_science · Post #3406 · 20.04.2025 г., 20:16
In 1978, Richard Branson wanted to impress his girlfriend by pretending to buy a private island. The island was listed for $6 million and he offered $100,000 as a joke. The owner settled for $180,000 and Branson bought Necker Island. #Human 🔔@Everything_Science
Hashtags
@everything_science · Post #3389 · 10.04.2025 г., 20:05
92-year-old woman graduated college, proving it is never too late. #Human 🔔@Everything_Science
Hashtags
@everything_science · Post #3387 · 09.04.2025 г., 16:18
Bill Gates owns a rare McDonald's Gold card that grants him free food for life. #Human 🔔@Everything_Science
Hashtags