简单的天气预报 (五)

4行Python代码获取所在城市的天气预报!最简单的爬虫实战 使用Python获取天气预报,想想是件很简单的事情。无非是发送一个HTTP请求,再解析请求返回的结果。当你真的使用Python程序去获取天气预报以后,会发现,有不少坑在等着你。这里简单记录一下我遇到的坑,供大家参考。 如何获取 使用Python获取天气有两种不同的方法,一种是像平时爬虫一样,获取天气预报网站的HTML页面,再使用XPath或BeautifulSoup解析HTML页面的内容。这是比... 阅读详情

本篇完成的任务主要是在我们选定城市后,显示该城市的天气。

在第三篇中,我们提到的工具类Utility里有一个方法叫做handleWeatherResponse,它利用json解析天气数据的;还有一个方法叫做saveWeatherInfo,它利用SharedPreferences来保存天气数据的,具体的请去第三篇中去看。网址:http://blog.csdn.net/guya1990/article/details/42711171


先看看显示天气的ui



它的代码为:

<span style="font-family:Microsoft YaHei;font-size:18px;"><?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="50dip"
        android:background="#484e61" >

        <Button
            android:id="@+id/switch_city"
            android:layout_width="30dip"
            android:layout_height="30dip"
            android:layout_centerVertical="true"
            android:layout_marginLeft="10dip"
            android:background="@drawable/home" />

        <TextView
            android:id="@+id/city_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:textColor="#fff"
            android:textSize="24sp" />

        <Button
            android:id="@+id/refresh_weather"
            android:layout_width="30dip"
            android:layout_height="30dip"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_marginRight="10dip"
            android:background="@drawable/refresh" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="50dip"
        android:background="#99ccff" >

        <TextView
            android:id="@+id/publish_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_marginRight="10dip"
            android:layout_marginTop="10dip"
            android:text="publish_text"
            android:textColor="#fff"
            android:textSize="18sp" />
    </RelativeLayout>

    <LinearLayout
        android:id="@+id/weather_info_layout"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="center_horizontal"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/current_date"
            android:layout_width="wrap_content"
            android:layout_height="40dip"
            android:gravity="center"
            android:text="current_date"
            android:textColor="#99cc33"
            android:textSize="18sp" />

        <TextView
            android:id="@+id/weather_desp"
            android:layout_width="wrap_content"
            android:layout_height="60dip"
            android:layout_gravity="center_horizontal"
            android:gravity="center"
            android:text="weather_desp"
            android:textColor="#99cc33"
            android:textSize="40sp" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="60dip"
            android:layout_gravity="center_horizontal"
            android:orientation="horizontal" >

            <TextView
                android:id="@+id/temp1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:text="temp1"
                android:textColor="#99cc33"
                android:textSize="40sp" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_marginLeft="10dip"
                android:layout_marginRight="10dip"
                android:text="~"
                android:textColor="#99cc33"
                android:textSize="40sp" />

            <TextView
                android:id="@+id/temp2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:text="temp2"
                android:textColor="#99cc33"
                android:textSize="40sp" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout></span>

代码很简单,由2个RelativeLayout组成。

第一个RelativeLayout里显示的是标题和两个按钮,两个按钮分别是刷新和重新选择城市。

第二个RelativeLayout里就是利用textView把我们json解析的内容放进去。


然后去实现逻辑代码。创建一个类:WeatherActivity,然后去清单文件里去注册一下。

在这个类中,我们主要完成以下几个任务。

mission1:

初始化ui代码里的控件

<span style="font-family:Microsoft YaHei;font-size:18px;">init();</span>
<span style="font-family:Microsoft YaHei;font-size:18px;">private void init() {
		weatherInfoLayout = (LinearLayout) findViewById(R.id.weather_info_layout);
		cityNameText = (TextView) findViewById(R.id.city_name);
		publishText = (TextView) findViewById(R.id.publish_text);
		weatherDespText = (TextView) findViewById(R.id.weather_desp);
		temp1Text = (TextView) findViewById(R.id.temp1);
		temp2Text = (TextView) findViewById(R.id.temp2);
		currentDateText = (TextView) findViewById(R.id.current_date);
		switchCity = (Button) findViewById(R.id.switch_city);
		refreshWeather = (Button) findViewById(R.id.refresh_weather);

	}</span>

mission2:

获取天气代码

<span style="font-family:Microsoft YaHei;font-size:18px;">         /**
	 * 查询县级代号对应的天气代号
	 * 
	 * @param countyCode
	 */
	private void queryWeatherCode(String countyCode) {
		String address = "http://www.weather.com.cn/data/list3/city"
				+ countyCode + ".xml";
		queryFromServer(address, "countyCode");
	}</span>

获取联网地址,然后去调用queryFromServer()方法去查询县级天气代号。查询完后会回调queryWeatherInfo()方法。

mission3:

根据天气代码去查询天气

/**
	 * 查询天气代号对应的天气
	 * 
	 * @param weatherCode
	 */
	private void queryWeatherInfo(String weatherCode) {
		String address = "http://www.weather.com.cn/data/cityinfo/"
				+ weatherCode + ".html";
		queryFromServer(address, "weatherCode");
	}

讲县级天气代码拼接后,调用queryFromServer方法去联网查询天气。


<span style="font-family:Microsoft YaHei;font-size:18px;">	private void queryFromServer(final String address, final String type) {
		HttpUtil.sendRequest(address, new HttpCallbackListener() {

			@Override
			public void onFinish(final String response) {

				if (type.equals("countyCode")) {
					if (!TextUtils.isEmpty(response)) {
						// 从服务器返回的数据中解析出天气代号
						String[] array = response.split("\\|");
						if (array != null && array.length == 2) {
							String weatherCode = array[1];
							queryWeatherInfo(weatherCode);
						}
					}
				} else if (type.equals("weatherCode")) {
					// 处理服务器返回的天气信息
					Utility.handleWeatherResponse(WeatherActivity.this,
							response);

					runOnUiThread(new Runnable() {
						public void run() {
							showWeather();
						}
					});
				}
			}

			@Override
			public void onError(Exception e) {
				runOnUiThread(new Runnable() {
					public void run() {
						publishText.setText("同步失败");
					}
				});
			}
		});

	}</span>


联网查询完天气之后,我们去调用runOnUiThread回到主线程去显示天气。
mission4:

显示天气

<span style="font-family:Microsoft YaHei;font-size:18px;">/**
	 * 从sharedPreferences文件中读取天气信息,并且显示到界面上
	 */
	private void showWeather() {
		SharedPreferences sp = PreferenceManager
				.getDefaultSharedPreferences(this);
		cityNameText.setText(sp.getString("city_name", ""));
		temp1Text.setText(sp.getString("temp1", ""));
		temp2Text.setText(sp.getString("temp2", ""));
		weatherDespText.setText(sp.getString("weather_desp", ""));
		publishText.setText("今天" + sp.getString("publish_time", "") + "发布");
		currentDateText.setText(sp.getString("current_date", ""));
		weatherInfoLayout.setVisibility(View.VISIBLE);
		cityNameText.setVisibility(View.VISIBLE);
	}</span>
调用本地sp里面的数据,显示天气。

自此,我们就大致描述完了显示天气的逻辑代码。下面给出全部代码。

package org.guya.myweather;

import org.guya.myweather.utils.HttpCallbackListener;
import org.guya.myweather.utils.HttpUtil;
import org.guya.myweather.utils.Utility;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class WeatherActivity extends Activity implements OnClickListener {
	private LinearLayout weatherInfoLayout;

	/**
	 * 用于显示城市名字
	 */
	private TextView cityNameText;
	/**
	 * 用于显示发布时间
	 */
	private TextView publishText;
	/**
	 * 用于显示天气描述信息
	 */
	private TextView weatherDespText;
	/**
	 * 用于显示温度1
	 */
	private TextView temp1Text;
	/**
	 * 用于显示温度2
	 */
	private TextView temp2Text;
	/**
	 * 用于显示当前日期
	 */
	private TextView currentDateText;
	/**
	 * 切换城市按钮
	 */
	private Button switchCity;
	/**
	 * 更新天气按钮
	 */
	private Button refreshWeather;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.weather_layout);
		init();
		String countyCode = getIntent().getStringExtra("county_code");
		if (!TextUtils.isEmpty(countyCode)) {
			// 有县级代号就去查询天气
			publishText.setText("同步ing");
			weatherInfoLayout.setVisibility(View.INVISIBLE);
			cityNameText.setVisibility(View.INVISIBLE);
			queryWeatherCode(countyCode);
		} else {
			// 没有县一级的code,直接查询显示本地天气
			showWeather();
		}
		switchCity.setOnClickListener(this);
		refreshWeather.setOnClickListener(this);
	}

	private void init() {
		weatherInfoLayout = (LinearLayout) findViewById(R.id.weather_info_layout);
		cityNameText = (TextView) findViewById(R.id.city_name);
		publishText = (TextView) findViewById(R.id.publish_text);
		weatherDespText = (TextView) findViewById(R.id.weather_desp);
		temp1Text = (TextView) findViewById(R.id.temp1);
		temp2Text = (TextView) findViewById(R.id.temp2);
		currentDateText = (TextView) findViewById(R.id.current_date);
		switchCity = (Button) findViewById(R.id.switch_city);
		refreshWeather = (Button) findViewById(R.id.refresh_weather);

	}

	@Override
	public void onClick(View view) {
		switch (view.getId()) {
		case R.id.switch_city:
			Intent intent = new Intent(this, ChooseAreaActivity.class);
			intent.putExtra("from_weather_activity", true);
			startActivity(intent);
			finish();
			break;
		case R.id.refresh_weather:
			publishText.setText("同步ing...");
			SharedPreferences sp = PreferenceManager
					.getDefaultSharedPreferences(this);
			String weatherCode = sp.getString("weather_code", "");
			if (!TextUtils.isEmpty(weatherCode)) {
				queryWeatherInfo(weatherCode);
			}
			break;

		default:
			break;
		}

	}

	/**
	 * 查询县级代号对应的天气代号
	 * 
	 * @param countyCode
	 */
	private void queryWeatherCode(String countyCode) {
		String address = "http://www.weather.com.cn/data/list3/city"
				+ countyCode + ".xml";
		queryFromServer(address, "countyCode");
	}

	/**
	 * 查询天气代号对应的天气
	 * 
	 * @param weatherCode
	 */
	private void queryWeatherInfo(String weatherCode) {
		String address = "http://www.weather.com.cn/data/cityinfo/"
				+ weatherCode + ".html";
		queryFromServer(address, "weatherCode");
	}

	private void queryFromServer(final String address, final String type) {
		HttpUtil.sendRequest(address, new HttpCallbackListener() {

			@Override
			public void onFinish(final String response) {

				if (type.equals("countyCode")) {
					if (!TextUtils.isEmpty(response)) {
						// 从服务器返回的数据中解析出天气代号
						String[] array = response.split("\\|");
						if (array != null && array.length == 2) {
							String weatherCode = array[1];
							queryWeatherInfo(weatherCode);
						}
					}
				} else if (type.equals("weatherCode")) {
					// 处理服务器返回的天气信息
					Utility.handleWeatherResponse(WeatherActivity.this,
							response);

					runOnUiThread(new Runnable() {
						public void run() {
							showWeather();
						}
					});
				}
			}

			@Override
			public void onError(Exception e) {
				runOnUiThread(new Runnable() {
					public void run() {
						publishText.setText("同步失败");
					}
				});
			}
		});

	}

	/**
	 * 从sharedPreferences文件中读取天气信息,并且显示到界面上
	 */
	private void showWeather() {
		SharedPreferences sp = PreferenceManager
				.getDefaultSharedPreferences(this);
		cityNameText.setText(sp.getString("city_name", ""));
		temp1Text.setText(sp.getString("temp1", ""));
		temp2Text.setText(sp.getString("temp2", ""));
		weatherDespText.setText(sp.getString("weather_desp", ""));
		publishText.setText("今天" + sp.getString("publish_time", "") + "发布");
		currentDateText.setText(sp.getString("current_date", ""));
		weatherInfoLayout.setVisibility(View.VISIBLE);
		cityNameText.setVisibility(View.VISIBLE);
	}
}

接下来就去是ChooseAreaActivity类里去添加Intent意图去跳转到显示天气的activity上。

分2个部分

1,如果之前,我们已经选择过了城市,那么就直接跳转到天气页面

SharedPreferences sp = PreferenceManager
				.getDefaultSharedPreferences(this);
		if (sp.getBoolean("city_selected", false)) {
			Intent intent = new Intent(this, WeatherActivity.class);
			startActivity(intent);
			finish();
			return;
		}

2,如果已经选择到了县级,那么就跳转到天气页面

listview.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View view, int index,
					long arg3) {
				if (currentLevel == LEVEL_PROVINCE) {
					selectedProvince = provinceList.get(index);
					queryCities();
				} else if (currentLevel == LEVEL_CITY) {
					selectedCity = cityList.get(index);
					queryCounties();
				} else if (currentLevel == LEVEL_COUNTY) {
					String countyCode = countyList.get(index).getCountyCode();
					Intent intent = new Intent(ChooseAreaActivity.this,
							WeatherActivity.class);
					intent.putExtra("county_code", countyCode);
					startActivity(intent);
					finish();

				}

			}
		});


运行程序,显示的结果是:








android制作一个简单的天气预报 最近由于要做一个关于天气的小应用,所以不得不费心上网开始搜索解决方案,找了几个网上疯传的免费的HTTP的接口,经过试验得到的数据都不是最新,发现还是去年的数据,最终找到一个百度地图接供的API的接口,但是首先需要获取一个开发者的密钥才行,所以第一步去注册得到一个密钥,然后是阅读该API的使用说明。 废话不多说,上API的说明: 接口说明 根据经纬度/城市名查询天气的结果 接口示例 http: 阅读详情

相关推荐

Android天气预报 简单Demo

最近在群里总是看到有人问到关于andro客户端如何和webService结合。 其中最多的就是关于实现天气预报这个应用的。但是群里很少有人回答, 我觉得可能那些大牛很忙,觉得实现这个不是很难,没有人去提示他们。 所以,像我们这种菜鸟 有的是时间,今天就把大体的实现思路写一下。 ,不废话了,先上图。 在这里我只写一下主要的步骤,至于源码会在最后给出。(其实源码写现在看来写的真的

谁人曾记负你多,一笑风云过 3402

一个简单的WebService调用天气预报接口的demo

很长一段时间没更新博客了,最近刚跳槽成功,工作也慢慢稳定下来了,后面也会陆陆续续更新。 现在的公司用到了WebService,以前没用过,所以学习一下记录下来。 什么是WebService? 首先附上百度百科地址:WebService 简而言之,WebService是一种跨语言跨平台的远程调用技术。我们知道,在我们的日常web开发中,都是我们自己开发接口,自己去调这些接口,但是有种情况:接...

Jqcode 1万+

天气预报的简单制作(一)

天气预报的开发创造 一、前期准备 功能需求:可以罗列出全国所有的省市县;可以查看全国任意城市的天气预报;可以自由切换城市;提供手动更新以级后台自动更新天气预报。 技术:UI、网络、数据存储、服务等等。 API:和风数据https://www.heweather.com/,申请注册,需要key值。 在com.coolweather.android里面建4个包,db用于存放数据库模型相关

zhaoliyinglm的博客 3758

使用网络技术—天气预报

一、功能需求及技术可行性分析 天气中至少应该具备以下功能。 1.        可以罗列出全国所有的省、市、县。 2.        可以查看全国任意城市的天气信息。 3.        可以自由地切换城市,去查看其他城市的天气。 4.        提供手动更新以及后台自动更新天气的功能。   二、界面效果图   三、核心代码

微爱的博客 927

固定资产报废的损失鉴定怎么做?

在社会生产的日常中,企业经常会遇到固定资产报废的损失鉴定,那么怎么去做鉴定?哪些情况下能申请固定资产报废损失鉴定呢? 今天,华碧鉴定就和大家说一说固定资产报废损失鉴定那些事儿。 符合下列条件之一的固定资产可申请报废: 1、使用年限过长,功能丧失,完全失去使用价值,或不能使用并无修复价值的; 2、产品技术落后,质量差,耗能高,效率低,已属淘汰且不适于继续使用,或技术指标已达不到使用要求的; 3、严重损坏,无法修复的或虽能修复,但累计修理费已接近或超过市场价值的; 4、主要附件损坏,无.

weixin_50362670的博客 2120

手把手教你用OpenCV+Python实现HALCON级模板匹配(附工业案例代码)

本文详细介绍了如何利用开源计算机视觉库OpenCV和Python,构建媲美HALCON商业软件的工业级模板匹配解决方案。通过分析工业检测的核心挑战,文章提供了从模板预处理、多策略融合匹配到应对尺度与旋转的完整代码实现,并附有连接器引脚检测的实战案例,为工业自动化场景下的高精度视觉检测提供了低成本、高可控性的技术路径。

e3f4g5的博客 288

Android开发中给服务器发送Http请求获取响应

在android中,有很多的情况都要用到网络的功能,而发送HTTP请求的代码基本上是一样的。所以我觉得很有必要将这些通用的操作提取到一个公共类里,并提供一个静态的方法,当想要发起网络请求的时候只需要简单的调用一下这个方法即可。发送HTTP请求的方式在安卓开发中一般有两种,HttpURLConnection和HttpClient。在这里采用HttpURLConnection的写法: public

活在当下!输出快乐! 1万+

卫星动力学仿真模型开发之AI初试

以下是通过AI生成的一个简单的C语言仿真模型,用于模拟卫星的姿态、轨道动力学和运动学。该模型基于基本的物理公式,假设卫星在近地轨道上运行,并忽略了一些复杂的扰动因素(如大气阻力、太阳辐射压等)。姿态动力学描述了卫星绕其质心的旋转运动。轨道动力学描述了卫星在引力作用下的运动。姿态运动学描述了卫星姿态随时间的变化。

xspace的博客 575

Android小程序-Walker解析天气(七)

目标效果:   输入城市名称点击按钮,会在下边的ListView中显示未来几天的天气情况。 1.程序素材:http://pan.baidu.com/s/1qYCHHhi 2.将素材中的图片文件夹直接替换项目原先的drawable-hdpi,libs文件夹替换原先的libs文件夹。 3.res目录下新建anim文件夹,用于存放ListView显示的动画效果页面。

Vivinia的博客 2792

YOLOv8工业级增强实战:小目标检测与HDR鲁棒性优化

YOLO(You Only Look Once)作为主流实时目标检测框架,其核心价值在于模块化架构与工程可扩展性。理解YOLOv8的Anchor-Free设计、C2f特征融合机制及Detect头部解耦原理,是实现性能突破的基础。在工业落地中,真实瓶颈往往不是模型版本迭代,而是小目标漏检、高动态范围(HDR)场景适应差、密集遮挡ID断裂等具体问题。通过配置层动态多尺度训练、物理感知数据增强、Neck跨尺度注意力注入、质量感知损失函数升级等七层增强策略,可在不更换主干的前提下显著提升mAP与边缘设备推理效率。本

weixin_32667439的博客 262

3D Slicer中文教程(三)—数据加载及保存方式

1.打开数据与保存数据 (1)打开数据 ——可以将数据拖拽到3D Slicer应用窗口或者从菜单栏工具栏打开。 ——多种方式加载大量数据。 有关DICOM数据,请参阅DICOM模块文档。 对于几乎所有其他(包括场景),您可以使用添加数据对话框。 有关支持的数据格式的列表,请参阅此列表。 请注意,仅部分支持列出的某些格式。 ——对于一些更复杂的格式(特别是DWI),建议首先使用DICOM到n...

weixin_33676492的博客 5543

关于对发送HTTP请求以及解析服务器返回的数据操作的提取到一个公共类中进行封装

创建一个名为HttpUtil的类并提供名为sendHttpRequest静态方法. 相关代码如下: package com.hzy.networktest; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.ne

Magician的博客 1712

深度探索:VS2022 牵手 DeepSeek,开启开发新征程

通过将 VS2022 与 DeepSeek 接入,我们成功开启了智能开发的新征程。从前期的硬件准备、软件环境搭建,到实战环节的一步步配置与整合,再到全面的测试与验证,每一个步骤都充满挑战,但也带来了满满的收获。在实际应用中,VS2022 与 DeepSeek 的结合展现出了强大的优势,为开发者带来了更高的效率和更出色的代码质量。无论是代码自动补全、智能代码审查,还是自然语言交互编程,都让开发过程变得更加智能、便捷,极大地提升了开发体验。

远程部署调试 运行安装 项目调试 二次开发 项目技术新 持续迭代 部分源码免费分享 3528

josn数据解析,建立定时服务(天气预报demo)

josn 解析 数据库设计,建立后台定时服务

NELA的博客 705

WPS文档中心和文档中台 operate 未授权访问漏洞(CVE-2025-0717)

WPS文档中心和文档中台的/open/v6/api/etcd/operate?key=/config/storage&method=get接口存在未授权访问漏洞,攻击者可通过该漏洞获取AK/SK密钥等信息,这些密钥通常用于系统内部认证和权限控制,泄露后可能导致攻击者进一步修改K8s配置、部署恶意容器或执行远程命令,最终实现对系统的完全控制。

李同學AI安全 914

基于知识图谱的时空事件关联推理能力培养

随着信息技术的飞速发展,大量的时空事件数据被产生和收集,如交通流量数据、气象观测数据、社交媒体上的地理定位信息等。这些数据蕴含着丰富的知识和规律,但要从中提取有价值的信息并非易事。基于知识图谱的时空事件关联推理旨在通过构建知识图谱,将时空事件数据进行整合和关联,从而实现对事件之间潜在关系的挖掘和推理。本文的目的是系统地介绍基于知识图谱的时空事件关联推理能力的培养方法,包括核心概念、算法原理、数学模型、实际应用等方面。

操作系统内核探秘的博客 753

Android上实现一个简单的天气预报APP(五) 解析XML

前面我们设置好了基本的屏幕布局、通过url获取到了网络中的天气预报数据,接下来我们要将这个XML格式的天气数据解析开来。 通过xmlPullParser解析xml数据 1.待解析的xml格式数据 2.根据标签值,获取标签数据 因为我们这个网页中fengli、fengxiang等标签出现了不止一次,因此我们设置了计数器以便只打印第一次 parseXML(String)函数如下:

赞美月亮的专栏 8708

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

kotlin 编写一个简单的天气预报app(五)增加forcast接口并显示

在天气app里增加了预测的功能并用列表显示

习惯就好zz的专栏 1134

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

Android上实现一个简单的天气预报APP(二) 配置布局

环境:Android Studio 配置布局文件,可以屏幕上的视图按照我们的设想摆放。 我们新建一个空的项目 File-New-New Project-Add no Activity,我给这个

赞美月亮的专栏 3万+

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

C#实现简单天气预报

(转载自:https://blog.csdn.net/cc0516123/article/details/78154772) 前言:老师作业要求:创建一个窗体应用程序或Web应用程序,实现查询全国各个城市的天气预报。无奈上网查询每个文章都有些小错误,所以想自己写一个。希望小白们可以一次做成。(提取天气预报网站网址:http://www.webxml.com.cn/WebServices/Wea...

帅boy的博客 7288

最简单的 天气预报 引入

一、前言1、目前引入天气预报的初衷仅仅是修饰页面而已,使网页稍微有点时代感,亲切感、体贴感。 2、全部前端引入,一句代码而已二、效果①初步显示②修改地区,如点击图中的湛江,进入如下页面修改为北京点击确定,如下图③查看天气预报详情,点击其他位置即可三、代码<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <

IT小村 3056

实现简单天气预报

实现简单天气预报

NiceGY 2153

使用Json实现简单天气预报查询

首先先在和天气注册一个账号获取key値 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>天气预报</title> <meta name="viewport" content="width=375,user-scalable=no...

v790873的博客 3905

天气预报发展简史:从玄学到科学

气象是一门科学,监测精密是基础,预报精准是核心,服务精细是目标。今天就和大家聊聊天气预报的前世今生!(对气象监测有兴趣的同志,请移步:气象监测,有多精密!) 天气预报一直深受人们的关注,深刻影响着人类的生产生活。天气预报从最初的玄学,纯粹依靠生活经验判断,到后来传统天气图的诞生,天气预报开始变为应用科学,再到现在的数值天气预报,预报准确率大幅提升,天气预报经历了从玄学到科学的演变历程: 一、早期天气预报的发展 三千年前,我国甲骨文中,就有了关于天气实况的记录,包括风、云、虹、雨、雪、霜、霞、.

Meteoforce的博客 8102

HTML、CSS和JavaScript实现简单天气预报

首先需要获取天气API的数据,可以通过向第三方天气数据服务商发送HTTP请求来获取数据。上面的代码中,先定义了要获取天气数据的城市和API Key,在JavaScript中使用fetch方法发送HTTP请求,获取数据后再使用DOM操作将数据渲染到HTML页面上对应的元素中。接着,将获取到的天气数据动态地展示在HTML页面上。可以使用JavaScript的DOM操作方法,将获取到的数据渲染到页面上指定的位置。最后,为了美化界面,可以使用CSS对整个天气预报页面进行样式设置。

m0_63359528的博客 9134
上一篇: 简单的天气预报 (四)
下一篇: 简单的天气预报 (六)
beginner-小菜鸟
博客等级 码龄15年 115粉丝 49原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值