zoukankan      html  css  js  c++  java
  • record-11 网络编程 打开文件

    #open()
    #urlopen()
    #方法名称不同
    #参数不同
    #只能以只读模式打开网络资源文件

    包名就是一个文件夹,包含许多的模块
    模块就是一个文件,文件里包含其他的函数之类的。详解:https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/0014318447437605e90206e261744c08630a836851f5183000 from urllib.request import urlopen from urllib.parse import quote from json import loads from time import time,sleep print('请输入要查询的城市名称:') s=input() s1=quote(s) #print(s1) url='http://www.sojson.com/open/api/weather/json.shtml?city='+s1 f=urlopen(url) #read() #readline() #readlines() result=f.read().decode() result=loads(result) #a=a+1 day1=result['data']['forecast'][0] print('日期:',day1['date']) print('天气状态:',day1['type']) print('风向:',day1['fx']) print('今天最低温度:',day1['low']) print('今天最高温度:',day1['high']) print('注意事项:',day1['notice']) f.close()

      

  • 相关阅读:
    使用CSVDE批量导入命令/出口AD用户
    Everything You Wanted to Know About Machine Learning
    android Vibrator 用法
    oc-25- @property @synthesize
    oc-24-点语法
    oc-23-static
    oc-22-sel
    oc-21-class对象
    oc-20-多态
    oc-19-成员变量修饰符
  • 原文地址:https://www.cnblogs.com/minkillmax/p/8313133.html
Copyright © 2011-2022 走看看