import requests
url = "https://www.templatemonster.com/ru/backgrounds/231926.html"
r = requests.get(url)
with open('file.html', 'w') as file:
file.write(r.text)
如果您在保存后打开此类站点,将出现问号而不是文本或图片。
import requests
url = "https://www.templatemonster.com/ru/backgrounds/231926.html"
r = requests.get(url)
with open('file.html', 'w') as file:
file.write(r.text)
如果您在保存后打开此类站点,将出现问号而不是文本或图片。
通常,您需要将给定单词的每个字母都变大。但是由于某种原因,当两个相同的字母彼此相邻时,它们都会变大。为什么会发生这种情况以及如何摆脱它?'HeLLo', 'HeLLo' => 'HeLlo', 'HellLo'
def wave(people):
count = 0
c = []
for i in range(len(people)):
c.append(people.replace(people[count],(people[count].upper())))
count += 1
return c
print(wave('Hello'))
['Hello', 'HEllo', 'HeLLo', 'HeLLo', 'HellO']
假设 Python 代码本身:
x = "tyr"
y = 'red'
result = []
for i in range(len(x)):
result.append((''.join(x[1] + (' - ') + y[1])).split())
print(result)
[['y', '-', 'e'], ['y', '-', 'e'], ['y', '-', 'e']]
但是如果你删除空间:
result.append((''.join(x[1] + ('-') + y[1])).split())
[['y-e'], ['y-e'], ['y-e']]
为什么会发生这种情况以及如何获得结果 [['y - e'], ['y - e'], ['y - e']],但不是通过替换。