我有包含域名的数据:
url var1
www.google.com xsd
ebay.com wer
www.amazon.com xyz
microsoft.com zyx
....
我需要添加“www.”的域名,没有它在开始。你知道吗
我有这个密码:
try:
for domain in df['url']:
if domain.startswith('www.'):
next
else:
domain = 'www.' + domain.astype(str)
except ConnectionResetError:
print('Handle Exception')
代码正在生成错误:
AttributeError: 'str' object has no attribute 'astype'
我做错什么了?你知道吗
我会这样做:
当可以
map()
在所有行上运行循环时,不要使用循环。你知道吗相关问题 更多 >
编程相关推荐