求救,为啥我的运行了 软件没有反应
import requests
def get_url(url):
headers = {'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36'}
res = requests.get(url,headers=headers)
return res
def main():
url = {'https://music.163.com/#/song?id=1363948882'}
res =get_url(url)
with open('res.txt','w',encoding='utf-8') as file:
file.write(res.text)
if "_name_"=="_main_":
main()
凌晨4点还在写代码,程序猿的生活这么苦逼?
alanliujin 发表于 2020-2-22 04:41
凌晨4点还在写代码,程序猿的生活这么苦逼?
hhhhhhhh if __name__ == '__main__':
main()
格式写错了 ```python
import requests
def get_url(url):
headers = {'user-agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 YaBrowser/19.12.0.769 Yowser/2.5 Safari/537.36'}
res = requests.get(url,headers=headers)
print(res.text)
return res
def main():
url = 'https://music.163.com/#/song?id=1363948882'
res =get_url(url)
with open('res.txt','w',encoding='utf-8') as file:
file.write(res.text)
if __name__ == '__main__':
main()
```
url 是 字符串没有大括号
还有if格式写错了改下就好了 这不应该发悬赏贴吗? 是不是没有配置环境 因为你压根没有输出任何东西 程序猿辛苦!帮顶一个! 不是有调试功能可发现错误语句吗?
页:
[1]
2