biglazycat 最近的时间轴更新
biglazycat

biglazycat

V2EX 第 504999 号会员,加入于 2020-08-23 03:21:34 +08:00
biglazycat 最近回复了
2021-03-23 06:36:56 +08:00
回复了 maloneleo88 创建的主题 Python 关于遍历列表,我这个错在哪了?百思不解
result = list(enumerate(ha))

for i in result[3::9]:
if ha[i[0]] == '0' and ha[i[0] + 1] == '0':
print(f"ha[{i[0] + 5}]: {ha[i[0] + 5]}")
2020-11-23 04:54:37 +08:00
回复了 WaterWestBolus 创建的主题 Python Python3 正则表达式问题
>>> s="![](/img/2020pic/02/1.jpg) 以及: ![](/img/2020pic/02/2.png)"
>>> re.findall(r'[/\w]+\/\w+\.\w+', s)
['/img/2020pic/02/1.jpg', '/img/2020pic/02/2.png']
@weyou 大神好厉害,牛 B 。
2020-10-24 16:01:09 +08:00
回复了 WaterWestBolus 创建的主题 Python Python3 正则表达式问题
line = "![](/img/2020pic/02/1.jpg) 以及: ![](/img/2020pic/02/2.png)"
pattern = re.compile('\((\S+)\)')
result = pattern.findall(line)
print(result)
2020-10-24 15:57:16 +08:00
回复了 qwa2013 创建的主题 Python Python 去重
2020-10-24 00:33:00 +08:00
回复了 qwa2013 创建的主题 Python Python 去重
import os
import re

domain_dict = {}
with open('mail.txt', encoding='utf-8') as f:
for line in f:
domain = re.split('@|:', line)[1]
domain_dict.setdefault(domain,[]).append(line)
for v in domain_dict.values():
print(v[0])

写的挺丑的,有更好的,我再回来贴上。
2020-09-12 07:12:45 +08:00
回复了 css3 创建的主题 Python 还得请教 Python 一个 dict 问题
mylist= {"key1": [{'a': '1'}, {'b': '2'}], "key2": [{"a": 2}, {"c": 4}]}

result = {}
for key, val in mylist.items():
for i in val:
result.setdefault(list(i)[0],[]).append(key)
print(result)
2020-09-12 07:03:07 +08:00
回复了 songdg 创建的主题 Python 判断是否字母的问题
def in_alphabet(char):
char = str(char)
if char.islower():
return 'LowerCase'
elif char.isupper():
return 'UpperCase'
else:
return 'NotInAlphabet'

print(in_alphabet('a'))
print(in_alphabet('A'))
print(in_alphabet(1))

写的很粗糙,目前的理解就写样了。请多多指教。
from datetime import datetime

time_list = []
now = datetime.now()
start_day_hour = int(now.strftime('%Y%m%d00'))
stop_day_hour = int(now.strftime('%Y%m%d%H'))
for i in range(start_day_hour, stop_day_hour + 1):
time_list.append(i)

print(time_list)
@weyou 大神,没看懂,请指点指点。
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2877 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 13:02 · PVG 21:02 · LAX 06:02 · JFK 09:02
Developed with CodeLauncher
♥ Do have faith in what you're doing.