Python 比特币编程实用指南(全)

资讯 2024-06-24 阅读:83 评论:0
原文:Original #xff1a; ˂a...
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

原文:

Original #xff1a;

译者:飞龙

Translator #xff1a;

协议:CC BY-NC-SA 4.0

Protocol & #xff1a; CC BY-NC-SA4.0

在本书中,您将介绍比特币和区块链,以及如何参与比特币生态系统。您将了解比特币及其特性、区块链以及两者如何共同工作。您还将学习如何使用 Pi 比特币工具来用 Python 编程比特币。您将学习如何使用 Python 以编程方式与区块链 API 进行交互,以及比特币挖矿以及如何开始进行。我们还将探讨比特币交易机器人。本书还涉及探索和分析比特币生态系统中产生的大量数据;如何获取、清理、操作和可视化比特币价格数据;以及如何使用 Python 的数据分析工具分析比特币骰子游戏的数据。

In this book xff0c; you will describe bitcoin and block chains xff0c; and how to participate in bitcoin ecosystems. You will learn about bitcoins and their properties, block chains and how they work together. You will also learn how to use Pibitco tools to use Python programming bitcoins. You will learn how to use Python to interact with block API in a programmed manner xff0c; and bitcoin mining and how to start. We will also explore bitcoin trading robots. The book also involves exploring and analysing a large amount of data generated in bitco ecosystems xff1b; how to obtain, clean, operate and visualize bitco prices #xff1b; and how to use Python data analysis tools to analyse bitco.

任何有一些 Python 经验的人都可以从本书中受益,他们希望探索 Python 比特币编程并开始构建基于比特币的 Python 应用程序。

Anyone with some Python experience can benefit from this book #xff0c; they want to explore Python bitcoin programming and start building Python applications based on bitcoin.

您可以从www.packtpub.com的帐户中下载本书的示例代码文件。如果您在其他地方购买了本书,您可以访问www.packtpub.com/support并注册,以便文件直接发送到您的邮箱。

You can download an example code file for the book from www.packtpub.com. If you have purchased a book xff0c; you can visit and register xff0c; so that documents can be sent directly to your mailbox.

您可以按照以下步骤下载代码文件:

You can download code files xff1a in the following steps;

  1. 登录或注册www.packtpub.com

    Login or registered at www.packtpub.com.

  2. 选择“支持”选项卡。

    Select the Support tab.

  3. 单击“代码下载和勘误”。

    Click " Code download and survey error ".

  4. 在搜索框中输入书名,然后按照屏幕上的说明操作。

    Enter the name & #xff0c in the search box; then operate as specified on the screen.

下载文件后,请确保使用最新版本的解压或提取文件夹:

xff0c after downloading files; please ensure that the most recent version of the folder is used to depress or extract xff1a;

  • WinRAR/7-Zip 适用于 Windows

    WinAR/7-Zip for Windows

  • Zipeg/iZip/UnRarX 适用于 Mac

    Zipeg/iZip/UnRarX for Mac

  • 7-Zip/PeaZip 适用于 Linux

    7-Zip/ PeaZip for Linux

本书的代码包也托管在 GitHub 上,网址为。如果代码有更新,将在现有的 GitHub 存储库上进行更新。

The book's code package is also hosted on GitHub & #xff0c; the address is . If the code is updated xff0c; it will be updated on the existing GitHub repository.

我们还提供了来自我们丰富书籍和视频目录的其他代码包,可在****上找到。来看看吧!

We also provided other code packages from our rich books and video catalogues xff0c; they can be found on a href="https://github.com/PacktPublishing/"**. Take a look at xff01;

我们还提供了一个 PDF 文件,其中包含本书中使用的屏幕截图/图表的彩色图片。您可以在这里下载:

We also have a PDF file & #xff0c; it contains colour pictures of screen screenshots/ charts used in this book. You can download & #xff1a; .

本书中使用了许多文本约定。

A number of textual agreements have been used in this book.

:表示文本中的代码词、数据库表名、文件夹名、文件名、文件扩展名、路径名、虚拟 URL、用户输入和 Twitter 句柄。这是一个例子:“使用函数从这些私钥创建三个公钥。”

& #xff1a; represents code words, database tabs, folder names, filenames, file extensions, path names, virtual URLs, user input and Twitter handles in the text. This is an example & #xff1a; "Use functions to create three public keys from these private keys."

代码块设置如下:

Code blocks are set as xff1a;

 

任何命令行输入或输出都以以下方式编写:

Any command line input or output is prepared as xff1a;

 

粗体:表示新术语、重要单词或屏幕上看到的单词。例如,菜单或对话框中的单词会以这种方式出现在文本中。这是一个例子:“屏幕截图显示了统计数据(DATA | Stats)”

bold : denotes new terms, important words or words seen on screen. For example, xff0c; words in menus or dialogue boxes appear in text in this way. This is an example of xff1a; “screenshot shows statistics xff08; DATA Stats)”

警告或重要提示会出现在这样的样式中。提示和技巧会出现在这样的样式中。

Warnings or important tips appear in this style. Tips and techniques appear in this style.

本章重点介绍比特币、其特点以及我们如何参与比特币生态系统。比特币生态系统由用户获取、花费和发送比特币钱包来运行。为了理解本章的概念,你应该至少对你所使用的计算机上的命令行有基本的了解,并且你的计算机上应该安装了 Python 3.x。

This chapter focuses on Bitcoin, its characteristics, and how we participate in the Bitcoin ecosystem. The Bitcoin ecosystem is operated by users who receive, spend and send bitcoin wallets. To understand the concept of this chapter xff0c; you should have at least a basic understanding of the command lines on the computer you use xff0c; and you should have Python 3.x installed on your computer.

在本章中,我们将探讨以下主题:

In this chapter xff0c; we will address the following themes xff1a;

  • 介绍比特币及其特点

    Introduction of bitcoin and its characteristics

  • 区块链的介绍

    Introduction to the block chain

  • 比特币和区块链的属性

    Properties of Bitcoin and Block Chains

  • 如何获取比特币钱包

    How to get a bitcoin wallet.

  • 包括获取、发送和花费在内的不同形式的比特币钱包

    Different forms of Bitcoin wallet, including acquisition, delivery and cost

在本节中,我们将探讨以下主题:

In this section xff0c; we will explore the following themes xff1a;

  • 比特币

    Bitcoin.

  • 比特币的用途

    Use of Bitcoin

  • 区块链

    Block Chain

  • 比特币和区块链的属性

    Properties of Bitcoin and Block Chains

比特币是一种数字货币。这意味着它只存在于电子记录中,与实体货币不同,你无法用手持有它。你可以使用比特币发送和接收货币(就像其他方法一样),以及用比特币支付物品和服务。比特币可以与传统货币互换。

Bitcoin is a digital currency. This means that it exists only in electronic records xff0c; unlike real currencies xff0c; you cannot hold it by hand. You can use bitcoin to send and receive currency xff08; xff09; xff0c; and pay goods and services in bitcoin. Bitcoin can be exchanged with traditional currencies.

有交易所可以购买和出售比特币。还有许多其他数字货币,但比特币是第一个也是最受欢迎的。比特币使用点对点技术运作,没有中央机构或银行管理交易,比特币的发行是由网络共同进行的。

There are exchanges where Bitcoins can be purchased and sold. There are many other digital currencies xff0c; but bitcoins are the first and most popular. Bitcoins use point-to-point technology operations xff0c; there is no central agency or bank to manage transactions xff0c; Bitcoins are issued by the network.

比特币是开源的——它的设计是公开的;没有人拥有或控制比特币,每个人都可以使用它。比特币是数字化的和去中心化的。历史上第一次,人们可以在没有中间人的情况下交换价值,这意味着对资金的更大控制和更低的费用。

Bitcoin is open source — it is designed to be open xff1b; nobody owns or controls it xff0c; everyone can use it. Bitcoin is digital and decentralized. For the first time in history xff0c; people can exchange value xff0c without intermediaries; this means greater control over money and lower costs.

它是一种加密货币,这意味着它是经过设计保护的。

It's an encrypted currency xff0c; that means it's designed to protect it.

使用比特币有很多优势。其中一些如下:

There are many advantages to the use of bitcoin. Some of them are xff1a;

  • 快速和简便的支付:使用比特币进行支付非常简单和快速。你不必担心使用哪种软件。比特币网络从不休息,即使在假期也是如此。国际间的支付也非常简单;没有银行让任何人等待三个工作日,也没有额外费用,也没有最低或最高金额的特殊限制。

    rapid and easy payment: payment in bitcoin is very simple and fast. You don't have to worry about the type of software you use. Bitcoin network does not rest xff0c; even during holidays. International payments are very simple xff1b; there are no banks that keep anyone waiting for three working days xff0c; there are no additional costs xff0c; and there are no special limits on the minimum or maximum amount.

  • 隐私:可以使用比特币进行支付而不分享任何个人信息;不需要注册或分享任何卡信息。事实上,甚至可以在不透露身份的情况下进行支付,几乎就像使用实体货币一样。但需要注意的是,保护隐私可能需要一些努力。

    Privacy: Bitcoin for payment without sharing any personal informationxff1b; no registration or sharing of any card information is required. In fact xff0c; even xff0c; almost like using a real currency. But note xff0c; privacy protection may require some effort.

  • 微不足道的交易费用:使用比特币进行支付时,交易费用非常少或微不足道。接收比特币时没有费用,拥有多个钱包可以控制在花费时支付多少费用。大多数钱包都有合理的默认费用,更高的费用可以加快交易的确认。费用与转账金额无关,因此可以用相同的费用发送 10 万比特币和发送 1 比特币。

    nominal transaction costs: transaction costs are very small or insignificant when paying in bitcoin. There is no fee xff0c when receiving bitcoin; multiple wallets can control how much is spent. Most wallets have reasonable default costs xff0c; higher costs can expedite the confirmation of transactions. Costs are not related to the amount transferred xff0c; hence they can be sent at the same cost of 100,000 bitcoins and 1 bitcoins.

  • 安全:比特币是通过电子方式创建和持有的,但没有涉及信用卡号,因此没有人可以盗取你的钱。交易使用军用级别的加密技术,非常保密。比特币将为你提供对资金的完全访问和高水平的保护,几乎可以防范所有类型的欺诈行为。

    security: Bitcoin is created and held electronically xff0c; however, no credit card number xff0c is involved; therefore no one can steal your money. The transaction uses military-level encryption technology xff0c; very secret. Bitcoin will provide you with complete access to and high level of protection against money xff0c; almost all types of fraud can be prevented.

  • 多重签名:比特币的多重签名功能允许企业通过只有一组人授权交易才能花费比特币来完全控制他们的支出。

    Multiple signatures & #xff1a; Bitcoin's multiple signature functions allow businesses to fully control their expenditures by authorizing transactions only by a group of persons.

  • 对开发者来说很好:对于开发者来说,比特币是最简单的支付系统。有许多第三方支付处理服务提供 API。我们不需要在服务器上存储比特币。如果不使用任何第三方 API,可以直接将比特币节点集成到应用程序中,使其成为自己的银行和支付处理器。

    is good for developers : xff0c; bitcoin is the easiest payment system for developers. There are many third-party payment processing services providing API. We do not need to store bitcoins on the server. API, is not used for any third party; bitcoin nodes can be incorporated directly into the application xff0c; they can be made into their own bank and payment processors.

简单来说,区块链是一个数字账本。它是比特币交易的公共记录,按时间顺序排列。它是一个基于比特币协议的无许可、分布式数据库,维护着不断增长的交易数据记录列表。它是分布式的,因此每个参与者都有整个区块链的副本。区块链在所有比特币用户之间共享。

Simplely xff0c; block chain is a digital book. It is a public record of bitcoin transactions xff0c; it is chronologically arranged. It is an unlicensed, distributed database based on bitcoin protocols xff0c; it maintains a growing list of transaction data records. It is distributed xff0c; thus each participant has a copy of the entire block chain. The block chain is shared among all bitcoin users.

它用于验证比特币交易的永久性,并防止双重支付。它是安全和不可变的,也经过了防篡改和修改,即使是数据存储节点的运营者也无法修改。

It is used to verify the permanent xff0c of Bitcoin transactions; and to prevent double payment. It is safe and immutable xff0c; it has also been tampered with and modified xff0c; it cannot be modified even by the operator of the data storage node.

每个区块链记录都经过密码验证,主机运行作为数据存储节点的机器。区块链由区块组成。区块是区块链中包含和确认许多等待交易的记录,如所示:

Each block chain record is authenticated with a password xff0c; the host runs the machine as a data storage node. The block chain consists of blocks. The block is a record that contains and confirms many pending transactions xff0c; for example xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

</p> 
<p>大约每十分钟,通过挖矿,一个包含交易的新区块被附加到区块链上。它是一个名为比特币区块链的文件,存储在世界各地数千台计算机上,甚至可能存储在你家里的个人电脑上。该文件包含有关所有比特币交易的数据,即从一个账户向另一个账户支付比特币的数据。</p><p>About ten minutes xff0c; by digging xff0c; a new block containing transactions is attached to the block chain. It is a document called xff0c in the Bitcoin block chain; stored on thousands of computers around the world xff0c; and possibly even on your personal computer. The document contains data on all bitcoin transactions xff0c; that is, paying bitcoin data from one account to another.</p> 
<p>这通常被称为<strong>账本</strong>,类似于银行账本,用于记录付款。</p><p>This is commonly known as </strang> account book</strang>, similar to the bank account xff0c; used to record payments.</p> 
 
<p>比特币和区块链都具有以下相似的属性:</p><p>Bitcoin and block chains have similar properties xff1a;</p> 
<ul><li> <p>区块链是比特币背后的技术。它就像是所有比特币交易的数据库,并自第一笔交易以来一直保留着所有比特币交易的记录。区块链技术最初和最广为人知的应用是比特币的交易公共账本。然而,数字货币并不是区块链技术的唯一用途。</p><p>The block chain is the technology behind Bitcoin. It's like a database of all bitcoin transactions xff0c; and records of all bitcoin transactions have been kept since the first transaction. The initial and most well-known application of block chain technology is the Bitcoin transactional public ledger. xff0c; digital currency is not the only use of block chain technology.</p> </li><li> <p>区块链是一个无信任的系统,可以用来进行各种交易,比如数字合同签署。区块链技术可以用来创建一个永久的公开透明的账本系统,用于编制销售数据,通过认证版权注册来存储权利数据等等。</p><p>Block chains are untrusted systems xff0c; they can be used for various transactions xff0c; e.g. digital contract signing. Block chain technology can be used to create a permanent open and transparent account system xff0c; to compile sales data xff0c; to store rights data by authenticating copyright registration, etc.</p> </li></ul> 
<p>甚至还有一个建立在区块链技术上的数字国家,名为<strong>Bitnation</strong>。</p><p>There is even a digital country based on block chain technology #xff0c, called <strung>Bitation</strang>.</p> 
 
<p>要开始使用比特币进行支付,我们需要一个比特币钱包。但是,在创建钱包之前,我们应该了解以下事项:</p><p>To start using bitcoin for payments xff0c; we need a bitcoin wallet. But xff0c; xff0c before the wallet is created; we should know the following: xff1a;</p> 
<ul><li> <p><strong>安全性</strong>:我们应该采取措施保护我们的钱包。不同的钱包有许多不同的功能。您应该评估所有这些功能,并选择最适合您的功能。</p><p><strong> security</strang>: we should take measures to protect our wallets. There are many different functions for different wallets. You should evaluate all these functions xff0c; and select the most suitable features for you.</p> </li><li> <p><strong>波动性</strong>:比特币价格波动很大,取决于市场条件。</p><p><strong> Volatility</strang>: Bitcoin price volatility xff0c; subject to market conditions.</p> </li></ul> 
<p>还有一些其他需要注意的事项。有关更多信息,请参阅<a href=

There are other matters that require attention. For more information, see .

比特币钱包有很多不同的形式。以下是其中一些:

Bitcoin wallets have many different forms. Here are some of them xff1a;

比特币可以从交易网站购买。交易网站的一个例子是 Coinbase.info,而 bitcoin.org 列出了许多这样的交易网站。一些是全球运营的,而一些是特定于某个国家或地区的,具体取决于该国家的法律。世界各地都有可用的交易所。例如,最受欢迎的之一是 Coinbase.com。在这里,可以发送和出售比特币,并且可以查看您的帐户详细信息,其中包含您持有的比特币信息。

Bitcoin can be purchased from a trading site. One example of a trading site is Coinbase.info, and bitcoin.org lists many of these trading sites. Some are globally operated xff0c; others are country- or region-specific xff0c; depending on the laws of the country. There are available exchanges around the world. xff0c; one of the most popular are Coinbase.com. Here xff0c; you can send and sell bitcoinxff0c; and you can see your account details xff0c; it contains the bitcoin information you hold.

您还可以从比特币 ATM 购买比特币。找到您当地比特币 ATM 的最佳网站之一是。例如,以下屏幕截图显示了美国的地图,您可以在上面看到所有可用的比特币 ATM,您可以在那里购买比特币:

You can also buy bitcoin from Bitcoin ATM. One of the best websites you can find in your local bitcoin ATM is . For example, xff0c; the screen screenshot below shows the map of the United States xff0c; you can see all available bitcoinATMxff0c; you can buy bitcoin#xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

chain

您还可以与其他用户面对面购买比特币。有兴趣出售比特币的人的位置可以在找到。在下面的屏幕截图中,我们可以看到所有有兴趣出售比特币的美国人。其他用户可以从该网站购买比特币。您还可以向有兴趣购买比特币的其他用户出售比特币:

You can also buy bitcoins face to face with other users. The location of people interested in selling bitcoins can be found at . On screen screen screen below xff0c; we can see all Americans interested in selling bitcoins. Other users can buy bitcoins from the website. You can also sell bitcoins@xff1a to other users interested in buying bitcoins;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

 image transfer failure of the external chain, possibly from the point of origin of origin, suggesting that the image be directly uploaded to the anti-piracy chain /></p> 
<p>还有很多地方可以在线使用比特币购买产品和服务。一个可以找到这些地方的网站是<a href=。从这个网站上,我们可以搜索接受比特币付款的卖家的产品。

There are a lot of places where you can buy products and services online. One site where you can find them is . From this site xff0c; we can search the product of the seller that receives the Bitcoin payment.

例如,当我们在搜索栏中搜索烤面包机时,它将显示所有愿意接受比特币付款的卖家的列表。

For example, xff0c; when we search the toaster in the search bar xff0c; it will show a list of all vendors willing to accept Bitcoin payments.

寻找接受比特币的企业的另一个地方是。该网站包含接受比特币付款的公司列表。如下列表所示,列出了许多知名公司的名称:

Another place to look for a company that receives Bitcoin is . The website contains a list of companies that receive payment from Bitcoin. xff0c; the names of many well-known companies are xff1a, as shown in the table below;

  • WordPress:允许用户创建博客

    WordPress: allows users to create blogs

  • Overstock:在线零售商

    overstock: online retailer

  • Subway:接受比特币

    Subway #xff1a; acceptance of Bitcoin

  • Microsoft:用户可以在 Windows 商店用比特币购买内容

    Microsoft/strangxff1a; user can purchase content in bitcoin at Windows store

  • Reddit:使用比特币购买高级功能

    Reddit: purchasing advanced functionality in bitcoin

如果您有兴趣寻找接受比特币的本地企业,您可以在 coinmap.org 上搜索。

If you are interested in finding a local firm that accepts Bitcoin & #xff0c; you can search on coinmap.org.

在本章中,我们介绍了比特币和区块链技术,以及我们如何开始在比特币生态系统中发挥作用。我们了解了比特币及其特性,区块链,比特币和区块链如何协同工作,以及它们之间的区别。我们还探讨了如何获取比特币钱包以及如何开始使用它。

In this chapter xff0c; we present bitcoin and block chain technology xff0c; and how we started to play a role in bitcoin ecosystems. We know bitcoin and its properties xff0c; block chains xff0c; bitcoin and block chains working together xff0c; and the difference between them. We also explore how to get bitcoin wallets and how to start using them.

我们学会了如何获取和发送比特币,并了解了在线和离线获取比特币的各种途径。我们看了如何发送比特币,并了解了一些可以花费比特币购买产品和服务的地方。

We learned how to get and send bitcoin #xff0c; we learned a variety of ways to get bitcoin online and offline. We saw how to send bitcoin #xff0c; and we found some places where bitcoin could buy products and services.

在下一章中,我们将以编程方式探索比特币和区块链 API,并了解如何开始挖掘比特币。

In the next chapter, xff0c; we will explore bitcoin and block chains API, in a programmed manner; and we will know how to start digging bitcoin.

本章重点介绍使用树莓派比特币工具来使用 Python 编程比特币,并以编程方式与区块链 API 进行交互。读者还将对挖掘比特币及其初始阶段的过程有一个大致的了解。

This chapter focuses on the use of the Python Python programming bitcoin & #xff0c, and interacts with block API by programming. Readers will also have a general understanding of the process of digging bitcoin and its initial phase.

在本章中,我们将学习以下主题:

In this chapter xff0c; we will study the following themes xff1a;

  • 使用 Python 编程比特币

    Program Bitcoin with Python

  • 创建多重签名比特币地址

    Create Multi-Signature Bitcoin Address

  • 使用 Python 进行区块链 API 编程

    Use Python for block chain API programming

  • 安装 Blockchain.info

    Install Blockchain.info

  • Python 库

    Python Library

  • 学习挖掘比特币

    Learn to dig bitcoin.

  • 如何挖掘比特币

    How to dig up bitcoin.

  • 挖掘比特币的困难增加

    The difficulty of digging bitcoin has increased.

在本节中,我们将介绍以下主题:

In this section xff0c; we will introduce the following theme xff1a;

  • 树莓派比特币工具库及如何开始使用它

    Berry Pittcoin and how to start using it.

  • 如何生成私钥和公钥

    How to Generate Private and Public Keys

  • 如何从生成的私钥和公钥创建一个简单的比特币地址

    How to create a simple bitcoin address from the generated private and public keys

要使用 Python 开始比特币,必须在系统中安装 Python 3.x 和名为 Pi 比特币工具的比特币 Python 库。

To start bitcoinxff0c using Python; Python 3.x and the Bitcoin Python library called Pibitcoin tools must be installed in the system.

要安装 Pi 比特币工具库,请打开命令行程序并执行以下命令:

To install the Pi Bitcoin Toolbar xff0c; please open the command line and execute the following command xff1a;

 

这个库最好的地方是,您不需要在计算机上安装比特币节点就可以开始使用它。

The best place for this library is xff0c; you do not need to install a bitcoin node on a computer to start using it.

此库连接到比特币网络,并从诸如 Blockchain.info 之类的地方获取数据。

This library is connected to the Bitcoin network & #xff0c; and obtains data from places such as Blockchain.info.

我们将首先用 Python 编写比特币的等价物。在脚本中,使用 Python 创建了一个新的比特币地址的演示。

We will start with a bitcoin equivalent in Python. In the script & #xff0c; a demonstration of a new bitcoin address was created using Python.

按照以下步骤运行程序:

Run the program xff1a in accordance with the following steps;

  1. 导入比特币库:
 
  1. 使用随机密钥函数生成私钥:
 
  1. 在屏幕上显示私钥:
 
 

使用私钥生成公钥。通过将生成的私钥传递给函数来执行此步骤,如下所示:

Private keys are used to generate public keys. This step is carried out by passing the generated private keys to a function xff0c; xff1a as shown below;

 

现在,使用公钥生成比特币地址。通过将生成的公钥传递给函数来实现:

& #xff0c; Generates a bitcoin address using a public key. accomplishes & #xff1a by transmitting the resulting public key to a function;

 

以下屏幕截图显示了生成的私钥、公钥和比特币地址:

The following screenshot shows the generated private keys, public keys and Bitcoin address xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

s

比特币地址

Bitcoin Address

比特币地址是一次性令牌。就像人们使用电子邮件地址发送和接收电子邮件一样,您可以使用此比特币地址发送和接收比特币。但与电子邮件地址不同,人们有许多不同的比特币地址,每个交易应使用唯一的地址。

The Bitcoin address is a one-time token. As people send and receive e-mails xff0c; you can send and receive bitcoin using this bitcoin address. But unlike e-mail addresses xff0c; people have many different bitcoin addresses xff0c; the only address should be used for each transaction.

多重签名地址是与多个私钥关联的地址;因此,我们需要创建三个私钥。

Multiple signature addresses are addresses associated with multiple private keysxff1b; thusxff0c; we need to create three private keys.

按照以下步骤创建多重签名比特币地址:

Create multi-signature bitcoin address xff1a in accordance with the following steps;

  1. 创建三个私钥:
 
  1. 使用函数从这些私钥创建三个公钥:
 
  1. 生成公钥后,通过将这三个公钥传递给函数来创建。将生成的传递给脚本函数以创建多重签名比特币地址。
 
  1. 打印多重签名地址并执行脚本。

以下屏幕截图显示了比特币地址的输出:

The following screenshot shows the output of the Bitcoin address xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传多重签名地址在组织中非常有用,因为没有单个个人被信任授权花费比特币。

 image transfer failure at the source station, which may result in a theft prevention chain mechanism, and it is recommended that the image be saved and sent directly to /> multiple signature addresses #xfff0; #fffffffffffff0.t.</p> 
<p>您还可以查看现有比特币地址的交易历史。我们将首先从 Blockchain.info 获取有效地址。</p><p>You can also see the history of the transactions at the existing bitcoin address. We will first get a valid address from Blockchain.info.</p> 
<p>以下屏幕截图显示了比特币区块的复制地址:</p><p>The following screenshot shows the copy address of the Bitcoin block xff1a;</p> 
<p><img src=

 images from the external chain may have failed, and it was suggested that the image be saved and sent directly up to / /></p> 
<p>将复制的地址传递给函数,如下面的代码所示,以及输出以获取比特币地址的历史记录,包括交易信息:</p><p>Passes the copied address to function xff0c; the code xff0c; and the output to obtain historical records of the Bitcoin address xff0c; including transaction information xff1a;</p> 
<pre></pre> 
<p><img src=

 images of the external chain may fail and the source station may have a chain-control mechanism, and it is suggested that the image be preserved and sent directly to />.</p> 
 
<p>Blockchain.info 是最受欢迎的区块链和比特币网络浏览器和钱包提供商之一。通过网络,您可以查看区块级别并查看所有已发生的交易。例如,通过转到特定的区块—即区块#536081—您可以查看所有交易,以及一些其他信息,如以下截图所示:</p><p>Blockchain.info is one of the most popular block chains and Bitcoin web browsers and wallet providers. Through the network & #xff0c; you can see block levels and all transactions that have taken place. For example, xff0c; xff0c; xff03; 536081 - you can see all transactions xff0c; and some other information xff0c; xff1a as shown in the screenshot below;</p> 
<p><img src=

s

以下截图显示了统计数据(DATA | Stats)。这很棒,也很有用;但是,对于基于此数据构建应用程序或进行分析的开发人员来说,以编程方式获取这些数据非常重要:

The following screenshot shows the statistics xff08; DATA Stats). This is good xff0c; it is also useful xff1b; but xff0c; xff0c for developers who build applications or conduct analyses based on this data; it is important to programme access to these data xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

Ear chain image transfer mechanism may have failed, and it is suggested that the image be saved and sent directly to /></p> 
<p>以下截图显示了市场数据(DATA | Markets):</p><p>The following screenshot shows market data xff08; DATA Markets) xff1a;</p> 
<p><img src=

</p> 
 
<p>以下是安装 Python 库的步骤:</p><p>Here are the steps to install the Python library #xff1a;</p> 
<ol><li> <p>在计算机上打开命令行程序。</p><p>Opens the command line on the computer.</p> </li><li> <p>运行命令来安装库。</p><p>Runs the command to install the library.</p> </li></ol> 
<p>以下截图显示了比特币的安装:</p><p>The following screenshot shows the installation of Bitcoin xff1a;</p> 
<p><img src=

chain

以下步骤显示了比特币汇率的方法:

The following steps show the Bitcoin exchange rate methodology xff1a;

  1. 首先从库中导入类:
 
  1. 汇率定义了一个方法,它返回字典对象中的汇率数据。调用此方法并保存结果对象。我们拥有的字典对象具有货币符号作为键:
 
  1. 通过运行这些键,可以获取有关各种汇率的数据。例如,可以通过获取最小值来获取每种货币的最新比特币汇率:
 

以下截图显示了各种货币及其相应的比特币汇率,即时或过去 15 分钟内:

The following screenshot shows the various currencies and their corresponding bitcoin exchange rate xff0c; instantaneous or past 15 minutes xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

Ears chain image transfer mechanism which may have occurred and suggested that the image be saved and sent directly to /></p> 
<p>特定货币也可以转换为比特币。例如,您可以传递方法,并传递我们要转换为的货币和金额,并将结果作为比特币获取。以下代码显示了如何对 100 欧元进行此操作:</p><p>A specific currency can also be converted to bitcoin. For example, xff0c; you can pass the method xff0c; you can pass the currency and the amount xff0c that we want to convert; and you can get the result as bitcoin. The following code shows how this operation is done for 100 euros xff1a;</p> 
<pre></pre> 
<p>以下截图显示了 100 欧元的比特币输出:</p><p>The following screenshot shows a bitcoin output of 100 euros xff1a;</p> 
<p><img src=

The external chain transfer of images may have failed and the source station may have been able to secure the chain of theft, and it is recommended that the image be preserved and sent directly to />.</p> 
 
<p>比特币区块链库的下一个类称为。</p><p>The next class of the Bitcoin block chain is called.</p> 
<p>有许多方法可以调用以获取各种区块链统计数据,例如以下截图所示:</p><p>There are a number of ways to leverage the various block chain statistics xff0c; for example, xff1a as shown in the screenshot below;</p> 
<p><img src=

 image transfer of the external chain may fail, and it is suggested that the image be saved and sent directly to />.</p> 
<p>您可以按以下方式调用不同的方法:</p><p>You can call different methods & #xff1a in the following ways;</p> 
<ul><li>导入相关类,调用上的方法,并保存该对象。例如,要获取比特币交易量,我们应该从创建的对象中获取属性,如以下代码所示:</li></ul> 
<pre></pre> 
<p>以下截图显示了比特币交易量:</p><p>The following screenshot shows the volume of Bitcoin transactions xff1a;</p> 
<p><img src=

</p> 
<ul><li>要获取总挖掘的比特币,请在对象上调用属性,如下所示:</li></ul> 
<pre></pre> 
<p>以下截图显示了挖掘的比特币数量的输出:</p><p>The following screenshot shows the output of the number of bitcoins excavated xff1a;</p> 
<p><img src=

offline

  • 要获取比特币市场价格,请使用类,调用市场价格并将其附加到特定货币:
 
  • 当前比特币价格以美元显示如下:

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

 image transfer of the external chain may fail and the source station may have a chain-control mechanism, and it is suggested that the image be saved and sent directly up to />.</p> 
 
<p>对于区块浏览器方法,首先从库中导入相关类。要获取特定的区块,请调用以下代码中显示的方法。它期望将一个区块作为参数传递。</p><p>For block browser methods & #xff0c; first import the class from the library. To get a specific block & #xff0c; call the method shown in the code below. It expects a block to be passed on as a parameter.</p> 
<pre></pre> 
<p>通过从网络上获取一个示例区块,从 Blockchain.info 上复制这个区块的哈希(区块#536081),并将其传递给方法,如下面的屏幕截图所示:</p><p>By obtaining an example block & #xff0c from the network; Hashi #xff08 from Blockchain.info; Block #xff03; 536081 #xff09; & #xff0c; and passing it to method xff0c; #xff1a from screen screen screen screens on the following;</p> 
<p><img src=

box

现在让我们获取有关这个区块的一些信息。例如,可以通过在创建的对象上分别使用、和属性来获取区块费用、区块大小和区块交易,如下面的代码所示:

Now let's get some information about this block. For example, xff0c; you can get block costs, block size and block transactions xff0c by using and properties on the created object separately; xff1a as shown in the code below;

 

以下屏幕截图显示了区块费用、区块大小和区块交易输出:

The screenshot below shows block costs, block size and block trade output xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

chain

Blockchain.info 库中还有许多可用的功能;其中一些与钱包、创建钱包等更相关。

There are also many available functions in the Blockchain.info library xff1b; some of them are more relevant to wallets, their creation, etc.

要进一步探索这个库,请访问链接

To further explore this library & #xff0c; please visit the link .

比特币挖掘的一些特点如下:

Some of the features of Bitcoin excavation are as follows xff1a;

  • 比特币挖矿是将比特币交易数据添加到比特币全球公共账本的过程。每个比特币矿工都与其他矿工一起合作,通过处理专门的分析和算术问题,将未完成的交易汇总到一个区块中。

    Bitcoin mining is the process of adding bitcoin trading data to the Bitcoin global public ledger. Each bitcoin miners work with other miners xff0c; by dealing with specialized analytical and arithmetic issues xff0c; and by synthesizing unfinished transactions into a block.

  • 为了获得准确性并解决问题,比特币矿工获取他们处理的所有交易。

    To obtain accuracy and solve problems xff0c; Bitcoin miners get all the transactions they handle.

  • 除了交易费用,矿工还会收到每个他们挖掘的区块的额外奖励。任何人都可以通过运行计算机程序参与比特币挖矿。除了在传统计算机上运行外,一些公司设计了专门的比特币挖矿硬件,可以更快地处理交易并构建区块。

    In addition to transaction costs xff0c; miners receive additional incentives for each of the blocks they dig. Anyone can participate in bitcoin mining by running a computer program. xff0c, apart from running on traditional computers; some companies have designed specialized bitcoin mining hardware xff0c; and they can process transactions and build blocks faster.

可以选择在上云端挖掘比特币。

You can choose to dig bitcoin on the cloud at .

这些计划的过程表明,比特币挖矿的难度正在增加,随着时间的推移变得更加昂贵。

The process of these plans shows that xff0c; that bitcoin mining is becoming more difficult xff0c; and that it is becoming more expensive over time.

一些公司购买专门的硬件来挖掘比特币。其中一种硬件是来自 21.co 公司的 21 比特币计算机。因此,这种硬件预先安装了必要的软件。

Some companies purchase specialized hardware to dig for bitcoins. One of the hardware is a 21 bitco computers. xff0c; this hardware is pre-installed with the necessary software.

还有许多可用的比特币挖矿软件,可以在任何机器上运行。然而,它可能不再那么高效。例如,让我们去查看这样的软件的长列表。它们可以在各种操作系统上运行:Windows、Linux 和 macOS。有基于 UI 的比特币矿工,也有基于命令行的比特币矿工,例如 Python 中的实现 Pyminer。

There are many other available bitcoin mining software xff0c; they can run on any machine. However, xff0c; it may not be as efficient. For example, xff0c; let's go to to see the long list of such software. They can run xff1a; Windows, Linux and macos on various operating systems. There are UI-based bitcoin miners #xff0c; there are also command-based bitcoin miners #xff0c; for example, Pyminer.

由于竞争和困难的增加,挖掘比特币时必须牢记许多因素,如下列表所示:

xff0c due to increased competition and difficulties; many factors must be borne in mind when digging bitcoin xff0c; xff1a as shown in the table below;

  • 由于竞争,比特币的价格日益昂贵

    Because of competition & #xff0c; Bitcoin is becoming more expensive

  • 全球许多超级计算机正在竞争挖掘下一个区块和比特币。

    Many supercomputers around the world are competing to dig the next block and bitcoin.

  • 随着比特币矿工数量的增加,开始挖掘新比特币变得更加困难和昂贵

    As the number of bitcoin miners increases xff0c; starting to dig for new bitcoin becomes more difficult and expensive

例如,以下屏幕截图显示了比特币挖矿难度的增加情况;有关更多信息,请参考。这张图表显示了过去两个月的数值。这一最近的趋势反映了比特币创立时开始的难度增加:

For example, xff0c; the following screenshot shows an increase in Bitcoin's difficulty in mining xff1b; more information xff0c; refer to . This graph shows values over the past two months. This recent trend reflects the increase in difficulties that Bitcoin began when it was created xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

chain

在本章中,我们学习了如何使用 Python 开始编程比特币。我们探索了使用 Python 进行 Blockchain.info API 编程,以获取统计数据和其他比特币市场数据。

In this chapter xff0c; we learned how to use Python to start programming bitcoin. We explored the use of Python for Blockchain.info API programming xff0c; to get statistics and other bitcoin market data.

我们还学习了如何开始挖掘比特币。我们看了看挖掘比特币的各种方式,并了解到由于竞争日益激烈和难度增加,比特币挖矿可能并不适合每个人。

We have also learned how to start digging bitcoin. We have looked at ways to dig bitcoin & #xff0c; we have learned that it may not be suitable for everyone because of increasing competition and difficulty #xff0c; bitcoin digs.

在下一章中,我们将学习如何通过在网站上接受比特币、运行基于 API 的微服务,或者构建比特币交易机器人来开始以编程方式运行比特币。

In the next chapter xff0c; we will learn how to start running bitcoin in a programmed manner by accepting bitcoin on the website, running API-based microservices xff0c; or building bitcoin trading robots.

在本章中,我们将学习如何在我们的网站上开始接受比特币作为支付方式。我们还将学习如何构建基于 API 的微服务以赚取比特币,并探索比特币交易机器人。

In this chapter xff0c; we will learn how to start accepting bitcoin as a payment on our website. We will also learn how to build API-based microservices to earn bitcoinxff0c; and explore bitcoin trading robots.

在本节中,我们将学习以下主题:

In this section xff0c; we will study the following themes xff1a;

  • 如何在我们的网站上启用比特币支付

    How to Enable Bitcoin Payments on our website

  • 介绍 BitPay,第三方比特币 API 服务

    Introduction Bitpay, third-party Bitcoin API service

  • 如何生成比特币支付按钮

    How to Generate Bitcoin Payment Buttons

  • 如何在我们的网站上添加比特币支付按钮

    How to add a bitcoin payment button to our website

有很多第三方 API 可用于网站上快速启用比特币支付,其中最流行的之一是 BitPay。

There are many third-party APIs that can be used to fast-track Bitcoin payments xff0c on the website; one of the most popular of these is Bitpay.

BitPay 可用于以多种不同的方式接受付款,包括以下方式:

Bitpay can be used to receive payments in a number of different ways xff0c; including the following mode xff1a;

  • 您可以使用比特币在电子商务网站上接受在线付款

    You can accept online payments using bitcoin on the e-commerce website.

  • 将比特币与许多不同的电子商务解决方案集成

    Integrating bitcoin with many different e-commerce solutions

  • 与购物车集成

    Combine with the shopping car.

  • 您可以显示启用比特币的支付按钮,这对于在博客或播客上接受捐赠非常有效

    You can show the payment button that enabled Bitcoin & #xff0c; this is very effective for accepting donations on blogs or podcasts

按照以下步骤生成比特币支付按钮:

Generate a bitcoin payment button based on the following steps & #xff1a;

  1. 首先,注册并登录 BitPay,网址为

    First xff0c; registered and entered Bitpay, address .

  2. 接下来,转到“支付工具|支付按钮”页面并创建支付按钮:

    Next xff0c;go to the payment tool payment button page and create the payment button xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

Ears chain image transfer mechanism possible, suggesting that the image be saved and sent directly to /></p> 
<ol><li>新字段需要安全服务器 POST 的 SERVER IPN,并且用户点击时会支付金额。您将在页面底部看到按钮的预览:</li></ol> 
<p><img src=

box

  1. 要将此按钮添加到网站,只需复制 HTML 代码并粘贴到所需的网页中。

按照以下步骤将支付按钮添加到您的网站页面:

Add payment buttons to your website page xff1a in accordance with the following steps;

  1. 在代码编辑器中打开您网站页面的源代码。

    Opens the source code for your website page in the code editor.

  2. 粘贴我们在上一节从 BitPay 网站复制的 HTML 代码,保存文件并重新加载网页。

    Paste the HTML code & #xff0c that we copied from the Bitpay website in the previous section; save files and reload pages.

  3. 以下截图显示了网页上的支付按钮,用户可以使用它发送付款:

    The following screenshot shows the payment button on the web page xff0c; users can use it to send payments xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

</p> 
 
<p>在本节中,我们将学习以下主题:</p><p>In this section xff0c; we will study the following themes xff1a;</p> 
<ul><li> <p>介绍 21.co 市场</p><p>21.CO MARKET</p> </li><li> <p>开始使用 21.co SDK</p><p>Start using 21.co SDK</p> </li><li> <p>开始为比特币出售服务</p><p>Start selling for bitcoin.</p> </li></ul> 
 
<p>21.co 是一个平台,托管了一个虚拟市场,开发人员可以在其中创建并出售微服务以换取比特币。有关更多信息,请参阅<a href=

21. Co is a platform & #xff0c; hosts a virtual market & #xff0c; developers can create and sell micro-services in exchange for Bitcoin. For more information & #xff0c; see .

我们将演示如何加入这个市场并出售微服务以赚取比特币。

We will demonstrate how to join the market and sell micro-services to earn bitcoin.

为此,我们将使用 21.co 的 SDK。

For this xff0c; we'll use 21.co's SDK.

21.co SDK 目前支持 Ubuntu 和 macOS。本节将演示在 AWS 上运行 Ubuntu 的情况。

21. Co SDK currently supports Ubuntu and macos. This section shows how Ubuntu is running on AWS.

您可以按照上的说明在 AWS 上创建 AWS Ubuntu 14.x 实例。

You can create an AWS Ubuntu 14.x example on AWS as specified on .

创建 AWS 实例后,请按照 AWS 文档页面上的说明连接到它,网址为

Creates an AWS example & #xff0c; connects to AWS document page & #xff0c; the address is .

连接到 AWS 实例后,安装 21.co SDK。您可以通过执行以下命令来完成:

After connecting to the AWS instance xff0c; install 21.co SDK. You can complete xff1a by executing the following commands;

 

安装 SDK 后,通过执行以下命令登录到您的 21.co 帐户:

Install SDK after xff0c; login to your 21.co account xff1a by executing the following command;

 

如果用户没有 21.co 登录,则必须在 21.co 网站上创建帐户。登录后,首先加入 21.co 节点到 21.co 虚拟市场。您可以通过执行以下命令来完成:

If the user does not have 21.co login & #xff0c; an account must be created on the 21.co website. After login & #xff0c; first joins the 21.co node to the 21.co virtual market. You can complete xff1a by executing the following command;

 

通过执行以下命令可以实现用户加入请求的状态:

The status of the user's request can be achieved by executing the following command xff1a;

 

接下来,通过执行以下命令测试安装:

Next xff0c; install xff1a by performing the following command tests;

 

上述命令将显示所有测试都已通过,并且节点已设置并加入了 21.co 市场。

The above command will show that all tests have passed xff0c; and nodes have been set and joined in the 21.co market.

为了获取比特币余额,执行以下命令:

To obtain the bitcoin balance xff0c; execute the following command xff1a;

 

上述代码显示了在 21.co 账户中持有的比特币余额。

The above codes show the bitco balance held in the 21.co account.

21.co 的 SDK 捆绑了一些服务。要启动所有这些服务,请执行以下命令:

21. The SDK of Co binds a number of services. To start all these services xff0c; please execute the following command xff1a;

 

可能会提示安装依赖项。如果是这样,您应该继续并执行。

Could be a reminder to install a dependent item. If so, xff0c; you should continue and execute it.

有时,用户可能需要注销并重新登录以进行更改。

Sometimes xff0c; users may need to write off and re-log for change.

在 21.co 市场上出售微服务,请执行以下步骤:

Sale of micro-services on the 21.co market xff0c; please implement the following steps xff1a;

  1. 执行以下命令:
 

它将显示所有可在虚拟市场上开始销售的微服务的列表。

It will show a list of all micro-services that can be sold on the virtual market.

  1. 要查看服务的状态,请执行以下命令:
 
  1. 完成服务后,或者如果要停止它,请运行以下命令:
 
  1. 要查看节点上发生的所有活动,请使用以下命令:
 

这是如何通过在 21.co 市场上出售和列出微服务来赚取比特币的演示。

This is a demonstration of how to earn bitco by selling and listing micro-services on the 21.co market.

在本节中,我们将学习以下主题:

In this section xff0c; we will study the following themes xff1a;

  • 如何获取比特币的当前出价和要价

    How to get the current bid and bid for bitcoin

  • 如何决定是否买入或卖出比特币

    How to decide whether to buy or sell bitcoin

  • 触发比特币交易建议警报

    Activate bitcoin trade advice alert.

实际的比特币买卖不会被涵盖,因为涉及实际货币。但是,我们将专注于根据我们设置的条件尝试买入或卖出比特币时发送电子邮件警报。

Actual bitcoin sales will not be covered by xff0c; because it involves real currency. But xff0c; we will focus on sending e-mail alerts when trying to buy or sell bitcoin under the conditions we set.

我们将使用比特币价格 API 模块来获取比特币价格。它可以在 GitHub 上找到

We will use the Bitcoin Price API module to get bitcoin prices. It can be found on GitHub at .

为了设置比特币交易建议警报,请按照以下步骤进行:

To set the recommended Bitcoin transaction alert xff0c; please follow the following steps xff1a;

  1. 首先,通过导入名为的比特币价格 API 开始:
 
  1. 还要导入,我们将用它来触发比特币价格警报。在这里,我们定义了一个名为的函数。然后设置服务器用户和电子邮件详细信息:
 
  1. 使用,发送函数发送价格警报电子邮件,如下面的代码所示:
 
  1. 接下来,为比特币定义买入和卖出价格阈值。使用这些阈值来决定是否卖出或买入比特币:
 
  1. 接下来,我们从 Bitfinex 比特币交易所使用我们在脚本中导入的模块获取当前比特币价格和当前出价。我们也可以使用其他交易所,如 CoinDesk,但目前我们将使用 Bitfinex。我们将在和中获取这些价格。
 
  1. 一旦我们得到了当前的价格,我们可以将它们与之前设置的阈值价格进行比较。

    Once we get the current price xff0c; we can compare them with the previously set threshold price.

  2. 如果买入价格低于卖出阈值,我们调用函数发送买入触发电子邮件警报:

    If the purchase price is below the selling threshold xff0c; we call the function to send the purchase to trigger e-mail alert xff1a;

 
  1. 如果卖出价格高于卖出阈值,我们调用函数发送卖出触发电子邮件警报:
 
 

谷歌搜索是搜索当前出价的最简单方法。为了实现比特币的买卖,应相应地触发两者。

Google search is the easiest way to search for the current bid. To achieve the purchase and sale of bitcoin xff0c; both should be triggered accordingly.

以下是获取当前出价的步骤:

Below are the steps to obtain the current bid #xff1a;

  1. 首先,检查比特币价格在线。

    First xff0c; check bitcoin prices online.

  2. 修改脚本,使买入警报首先触发。将买入阈值设置为高于当前价格。在这里,我们将买入阈值设置为,如下面的代码所示:

    Modify the script & #xff0c; triggers the purchase alarm first. Set the purchase threshold to higher than the current price. Here xff0c; we set the purchase threshold to xff0c; xff1a as shown in the code below;

 
  1. 保存脚本并执行它。以下屏幕截图显示了执行的脚本:

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

s

脚本已执行,买入警报应该已经发出。在电子邮件中检查。

Script executed xff0c; purchase alarm should have been sent. Check in email.

以下屏幕截图显示,根据我们在脚本中设置的标准,我们已收到比特币警报电子邮件,建议我们购买比特币:

The screen screenshot below shows xff0c; according to the standards we set in the script xff0c; we have received the Bitcoin alert e-mail xff0c; we are advised to purchase bitcoinxff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

failure

  1. 最初,我们应该将出售门槛设置为低于当前价格。例如,让我们将作为门槛,并再次执行脚本。以下代码显示了设置为:
 

现在,出售警报应该执行。再次在电子邮件中验证。

Now xff0c; sales alarms should be executed. Verify again in e-mail.

  1. 验证后,我们应该看到我们已收到电子邮件警报,建议我们出售比特币,因为当前的要价高于我们愿意出售的价格:

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

Ear chain image transfer mechanism possible from the source station and recommends that the image can be directly uploaded

  1. 脚本已准备好。您现在可以将其设置为在各种操作系统上自动运行。在 Windows 上,请使用任务计划程序。

    Script is ready. You can now set it to run automatically on various operating systems. On Windows & #xff0c; please use the task plan program.

  2. 从“操作”菜单中,选择“创建任务…”,并将其命名为“比特币交易警报”,如下面的屏幕截图所示:

    From the Operation menu & #xff0c; select "Creating Tasks..." & #xff0c; and name it "bitcoin Transaction Alert" & #xff0c; xff1a as shown in the screen screenshot below;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

 Image transfer of the external chain may have failed and the source station may have a chain-control mechanism, and it is recommended that the image be preserved and sent directly to />.</p> 
<ol><li>从“触发器”选项卡中,单击“新建…”,如下面的屏幕截图所示:</li></ol> 
<p><img src=

Ears chain image transfer mechanism which may have occurred and suggested that the image be saved and sent directly to /></p> 
<ol><li> <p>选择“每日”单选按钮。</p><p>Select the Daily Single Select button.</p> </li><li> <p>然后,在高级设置中,选择在所需的分钟数或小时数后重复任务。在这里,我们将其设置为每 1 小时,如下面的屏幕截图所示:</p><p>xff0c; in advanced settings xff0c; selects to repeat tasks after the number of minutes or hours required. Here xff0c; we set it to xff0c every 1 hour; xff1a as shown in screen screenshot below;</p> </li></ol> 
<p><img src=

 image transfer of the external chain may have failed and the source station may have a chain-control mechanism, and it is suggested that the image be saved and sent directly to />.</p> 
<ol><li> <p>接下来,从“操作”选项卡中,单击“新建…”按钮。</p><p>Next & #xff0c; #xff0c from the Operation tab; click on the New... button.</p> </li><li> <p>通过单击“浏览…”按钮选择要在任务运行时执行的脚本。现在,此任务将每小时自动运行,并将检查比特币价格,并发送电子邮件建议我们是否买入或卖出比特币。</p><p>Select the script to be performed while the task is running by clicking the Browse... button. Now xff0c; the task will run xff0c per hour automatically; the price of bitcoin xff0c will be checked; and e-mail advice will be sent as to whether to buy or sell bitcoin.</p> </li></ol> 
<p><img src=

s

您还可以选择直接从脚本中触发交易,使用任何比特币交易所 API,例如 coinbase.com。由于涉及实际资金,用户需要小心处理。

You can also choose to trigger a transaction from a script directly xff0c; use any bitcoin exchange API, e. g. coinbase.com. Due to actual funds xff0c; users need to be careful.

在本章中,我们探讨了如何在网站上启用比特币支付,向您介绍了 BitPay,学习了如何生成比特币支付按钮,以及如何将支付按钮添加到我们的网站上。我们还介绍了 21.co 市场和比特币的买卖服务,以及编写了一个简单的比特币交易机器人。我们学会了如何获取比特币的当前竞价和要价。我们还学会了如何决定是买入还是卖出比特币,以及如何发送电子邮件警报,建议我们是否执行该线程。

In this chapter xff0c; we have explored how to use Bitcoin to pay xff0c; we have introduced BitPay, to you; we have learned how to generate bitco payment buttons xff0c; and how to add payment buttons to our website. We have also introduced 21.co and Bitco's sales services xff0c; and we have developed a simple bitco trading robot. We have learned how to get Bitco's current bid and bid. We have also learned how to decide whether to buy or sell bitco xff0c; and how to send e-mail alerts xff0c; we have suggested whether to execute the thread.

在下一章中,我们将学习如何对比特币数据进行数据分析。

In the next chapter, xff0c; we will learn how to compare the data with the data.

在本章中,我们将使用 Python 探索比特币价格数据的操作和可视化。我们还将探索比特币交易图表,以及使用 Python 收集和分析比特币骰子游戏数据。

In this chapter xff0c; we will use Python to explore the operation and visualization of bitcoin price data. We will also explore bitcoin trade charts xff0c; and use Python to collect and analyse bitco dice game data.

在本节中,我们将介绍以下主题:

In this section xff0c; we will introduce the following theme xff1a;

  • 为数据分析做好准备

    Preparing for data analysis

  • 获取、读取和清理比特币价格数据

    Obtain, read and clean bitcoin price data

  • 探索、操作和可视化清理后的数据

    Explore, operate and visualize post-cleaning data

我们首先需要安装几个 Python 库,其中包括安装模块用于读取数据,以及进行一些探索性分析。我们还将安装用于创建图表和图表,以及 Jupyter 笔记本,因为它们是进行数据分析的最佳工具。

We first need to install several Python libraries & #xff0c; these include modules to read data & #xff0c; and some exploratory analysis. We will also install charts and graphs & #xff0c; and Jupyter notebooks & #xff0c; they are the best tools for data analysis.

要安装 Python 模块,请打开命令行程序。在命令行中,要安装,请执行以下命令:

To install the Python module & #xff0c; to open the command line. In the command line xff0c; to install xff0c; to execute the following command xff1a;

 

类似地,要安装,请执行以下命令:

Similar to xff0c; to install xff0c; please execute the following command xff1a;

 

要安装 Jupyter,请执行以下命令:

To install Jupyter, please execute the following command xff1a;

 

完成安装所需的模块后,通过执行命令启动 Jupyter Notebook。这将在新的浏览器窗口或选项卡中打开,显示已经存在于我们执行命令的文件夹中的文件列表。以下屏幕截图显示了命令:

xff0c after completion of installation of the required module; start the Jupyter Notebook by executing the command. This opens xff0c in the new browser window or tab; displays the list of files that already exist in the folder where we execute the command. The screenshot below shows the command xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

)

接下来,选择创建一个新的 Python 3 笔记本,如下屏幕截图所示:

Next xff0c; Select to create a new Python 3 notebook xff0c; xff1a as shown in screenshot below;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

 image transfer failure of the external chain, possibly from the point of origin of origin of which the anti-piracy chain could be stored, and it was suggested that the image should be directly uploaded

还要导入以从数据中绘制图表。

Import to draw a chart from the data.

我们需要为和设置一些选项。以下屏幕截图显示了导入的命令:

We need to set some options. The screenshot below shows the imported command #xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

spill

我们将设置的第一个选项称为。

We'll call the first option set.

前面的选项是确保清理操作是在 pandas DataFrame 对象上执行的;我们希望清理操作发生在原始 DataFrame 对象上,而不是在副本上。

The first option is to ensure that the clean-up operation is performed on a pandas DataFrame object xff1b; we want the clean-up operation to take place on the original DataFrame object xff0c; not on a copy.

以下屏幕截图显示了选项:

The screenshot below shows options & #xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

 image transfer failure of the external chain, possibly from the point of origin, suggesting that the image be directly uploaded

还要设置以可视化和显示以下屏幕截图中显示的所有图表:

Also set to visualize and display all charts & #xff1a shown in screen screenshots below;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

Ear chain image transfer mechanism possible, suggested that the image be saved and sent directly up

我们的价格数据来自,如下屏幕截图所示,它可以免费下载:

Our price data are from xff0c; xff0c as shown on screen screen screen below; it can be downloaded free of charge xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

Ear chain image transfer mechanism which may have occurred and suggested that the image be saved and sent directly to /></p> 
<p>以 CSV 格式下载数据并使用读取这些数据。这是一个 CSV 文件,所以我们将使用的方法,如下屏幕截图所示:</p><p>Download data in CSV format and use the data to read them. This is a CSV file xff0c; so the method we will use xff0c; xff1a as shown in the screenshot below;</p> 
<p><img src=

 Outside Chain image transfer failure at the source station, suggesting that the image be preserved and sent directly to / /></p> 
 
<p>pandas 数据对象中的数据称为 DataFrame。DataFrame 是以表格形式的数据格式。现在,打印一些记录以查看其外观。要打印出来,我们可以在价格 DataFrame 上调用一个名为的方法。</p><p>The data in the pandas data object is called DataFrame. DataFrame is a data format in the form of a table. Now & #xff0c; print some records to see its appearance. & #xff0c; we can call a named method at the price DataFrame.</p> 
<p>这样做后,我们会得到两列——和——表示当天比特币的美元价格。我们还有一个默认索引,从 0 开始的行,这是由在读取数据时默认插入的。以下屏幕截图显示了两列,和:</p><p>After doing so xff0c; we'll get two columns -- and -- representing the dollar price of Bitcoin that day. We also have a default index xff0c; line xff0c, starting with 0; this is inserted by default when reading the data. The screenshot below shows two columns xff0c; and xff1a;</p> 
<p><img src=

Ear chain image transfer mechanism may have failed and it is suggested that the image be saved and sent directly up to / /></p> 
<p>要获取有关此数据的顶级信息,请在其上调用方法。调用此方法后,我们得到 2,592 条记录。有两列:和。有 2,592 条非空记录,类型为对象,这意味着字段已被读取为文本。我们稍后需要将其更改为正确的日期时间格式。我们有收盘价作为数值浮点类型。它有 2,590 条非空记录,比字段少两条记录。</p><p>To get top-level information about this data xff0c; Please call it up. After calling this method xff0c; we get 2,592 records. There are two columns xff1a; and. There are 2,592 non-empty records xff0c; type xff0c; this means that the field has been read to text. We need to change it later to the correct date time format. We have collected the price as a value float type. It has 2,590 non-empty records xff0c; two records less than the field.</p> 
<p>以下截图显示了方法的详细信息:</p><p>Detailed information on the methodology is shown in the following screenshot xff1a;</p> 
<p><img src=

F3

为了打印底部的记录,调用方法。该方法显示最后两条记录不应该存在,因为它们不是日期或价格。在进行进一步分析之前,我们需要删除这些记录。

This method shows that the last two records should not exist xff0c; they are not dates or prices. Before further analysis xff0c; we need to delete these records.

我们可以看到收盘价有 NaN 值,这意味着它有缺失值。我们可以利用这一因素从 DataFrame 中删除这两条记录。我们在价格上调用方法,这将删除具有一个或多个列为空或缺失值的记录。

We can see that the collected price is NaN & #xff0c; this means that it has missing values. We can use this factor to delete both records from DataFrame. We call the price method & #xff0c; this removes one or more records with empty or missing values.

请记住,我们只是从 DataFrame 价格中删除它,而不是从我们读取数据的 CSV 文件中删除它。

Remember & #xff0c; we just delete it from DataFrame prices & #xff0c; not from the CSV file where we read the data.

以下截图中的代码显示了方法的实现:

The code in the screenshot below shows how the method is achieved xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

image

此外,再次查看底部行,看看我们想要删除的记录是否已经被删除。我们可以在以下截图中看到,实际上已经被删除了:

In addition, xff0c; again check the bottom line xff0c; see if the records we want to delete have been deleted. We can see xff0c in the following screenshot; xff1a has actually been deleted;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

image.

我们需要做的另一个数据清理任务是将列从对象或文本格式转换为日期时间格式。我们使用 pandas 的方法来实现这一点。

Another data cleansing task we need to do is to convert columns from object or text format to date time format. We use the pandas method to do this.

在这里,我们要求方法将字段或 DataFrame 转换,并且我们还提供了格式。然后我们将字段重新分配给 DataFrame,如下截图所示:

Here's xff0c; we're asking for ways to convert fields or DataFrame xff0c; and we're also providing formatting. Then we reassign the field to DataFrame, see xff1a in the screenshot below;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

 image transfer of the external chain may fail, and it is suggested that the image be saved and sent directly up to />.</p> 
<p>这就是我们将链式赋值设置为的原因,因为我们希望在原始 DataFrame 上进行更改。</p><p>That's why we set the chain value & #xff0c; because we want to change it on the original DataFrame.</p> 
<p>再次调用方法,查看数据清理是否产生影响。我们可以看到字段现在是日期时间格式,正如我们想要的那样,并且数据中没有非空记录,如下截图所示:</p><p>Recall method xff0c; see if the data cleanup has an impact. We can see that the field is now a date time format xff0c; xff0c as we want; and there are no non-empty records xff0c in the data; xff1a as shown in the screenshot below;</p> 
<p><img src=

image

我们还需要将索引设置为列,并将列删除为单独的列。这将帮助我们对日期数据运行一些有趣的查询。

We also need to set the index to column #xff0c; and delete the column as a separate column. This will help us run some interesting queries about date data.

以下截图中的代码显示了如何将索引设置为列:

The code in the following screenshot shows how the index is set to column #xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

 image transfer of the external chain may fail and the source station may have a chain-control mechanism, and it is suggested that the image be preserved and sent directly up to />.</p> 
<p>接下来,删除列作为单独的列,因为它已经设置为索引,如下截图所示:</p><p>Next xff0c; delete column as a separate column xff0c; as it has been set up as an index xff0c; xff1a as shown in the screenshot below;</p> 
<p><img src=

 Image transfer of the external chain may fail and the source station may have a chain-control mechanism, and it is recommended that the image be preserved and sent directly to />.</p> 
<p>现在,列可以看作是索引,而不再是一个单独的列,如下截图所示:</p><p>xff0c; column can be considered as an index xff0c; instead of being a separate column xff0c; xff1a as shown in the screenshot below;</p> 
<p><img src=

)</p

数据清理完成后,开始进行数据探索任务。我们可以使用 pandas 日期时间功能运行一些有趣的查询。

After data cleansing xff0c; data exploration tasks are started. We can run some interesting queries using the pandas date time function.

例如,如果我们想要获取特定年份的所有记录,将该年份传递给 DataFrame 内的方括号。以下截图显示了 2010 年的价格数据:

For example xff0c; if we want to get all records for a given year xff0c; pass that year to the square brackets in DataFrame. The following screenshot shows price data for 2010 xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

我们还可以指定我们是否要从特定日期获取数据。

We can also specify whether we want to obtain data from a specific date.

以下截图显示了 2017 年 8 月 1 日的比特币价格:

The following screenshot shows the Bitcoin price of xff1a on 1 August 2017;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

Earlinkage control mechanism possible, suggesting that the image be saved and sent directly to /></p> 
<p>我们还可以指定我们是否要从特定日期跨越一定日期的特定期间获取数据。</p><p>We can also specify whether we want to obtain data from a specified date over a specified period of time.</p> 
<p>以下屏幕截图显示了 2017 年 8 月 1 日以后的数据:</p><p>The following screenshot shows data after 1 August 2017 xff1a;</p> 
<p><img src=

 image transfer of the external chain may fail and it is recommended that the image be saved and sent directly up by the chain mechanism.</p> 
<p>还可以使用 pandas 方法检索统计信息。例如,要从数据集中获取最低价格,我们可以使用方法,如下图所示:</p><p>Statistical information can also be retrieved using the pandas method. For example, xff0c; minimum price xff0c from the data pool; we can use methods xff0c; xff1a as shown in the figure below;</p> 
<p><img src=

 image transfer failure of the external chain, possibly from which there is a chain of anti-piracy control, suggesting that the image be directly uploaded

要获取最高价格,使用方法,如下图所示:

To obtain the maximum price xff0c; method of use xff0c; xff1a as shown in the figure below;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

</p> 
<p>可以使用方法一次性获得大量统计信息,如下图所示:</p><p>A large amount of statistical information can be obtained on a one-time basis using the methodology; xff0c; xff1a as shown in the figure below;</p> 
<p><img src=

 Image transfer of the external chain may fail and the source station may have a chain-control mechanism, and it is recommended that the image be preserved and sent directly to />.</p> 
 
<p>使用和从数据开始创建图表非常容易。要绘制整个数据,我们将在 上调用方法,然后将得到一个图表,其中<em>x</em>轴是日期,<em>y</em>轴是价格数据。</p><p>It is very easy to use and start with data. To draw the entire data & #xff0c; we will call the method & #xff0c; then we will get a chart & #xff0c; <em>x</em> axis is date xff0c; <em>y</em> axis is price data.</p> 
<p>以下屏幕截图描述了绘图,其中<em>x</em>轴是日期,<em>y</em>轴是价格数据:</p><p>The following screenshot depicts the drawings xff0c; of which the axis <em>x</em> is the date xff0c; the axis <em>y</em> is the price data xff1a;</p> 
<p><img src=

failure

我们还可以放大到特定的时间段。例如,为了仅绘制 2017 年的数据,首先选择来自 2017 年的数据,然后在数据子集上调用方法。

We can also zoom into specific time periods. For example, xff0c; to draw data only for 2017 xff0c; first to select data from 2017 xff0c; and then to call methods on the subset of data.

在下图中,我们有 2017 年以后的价格数据的图表:

In the figure below xff0c; we have price data after 2017 xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

 image transfer of the external chain may fail and the source station may have a chain-control mechanism, and it is recommended that the image be saved and sent directly to />.</p> 
<p>在接下来的部分,我们将学习如何使用比特币交易图。</p><p>In the next part of #xff0c; we'll learn how to use bitcoins.</p> 
 
<p>在本节中,我们将学习如何获取区块链数据,并提供逐步信息,以便探索、清理、分析和可视化这些数据。</p><p>In this section xff0c; we will learn how to access block chain data xff0c; and provide step-by-step information xff0c to explore, clean, analyse and visualize these data.</p> 
 
<p>是查看最新比特币统计数据和图表的最佳地方之一。有关比特币和区块链的不同类型的图表和图形可供分析。我们还可以以各种格式(CSV、JSON 等)下载数据。在上一节中,我们已经以 CSV 格式下载了部分数据,现在我们将在 Jupyter Notebook 中探索这些数据。</p><p>This is one of the best places to look at the latest bitcoin statistics and graphs. Different types of charts and graphics about bitcoins and block chains can be analysed. We can also download data in various formats & #xff08; CSV, JSON, etc. & #xff09; in the previous section & #xff0c; we have downloaded some of the data xff0c in CSV format; now we will explore them in Jupyter Notebook.</p> 
<p>我们首先导入所需的模块。我们需要来读取、探索和清理数据,还需要来创建图表。</p><p>We first import the required modules. We need to read, explore and clean the data #xff0c; we need to create charts.</p> 
<p>查看显示流通中比特币总数的数据。读取包含此数据的 CSV 文件,并创建一个 。</p><p>View data showing the total number of bitcoins in circulation. Read the CSV file & #xff0c; and create one.</p> 
<p>以下屏幕截图显示了流通中比特币的总数量的数据:</p><p>The following screenshot shows the total number of bitcoins in circulation xff1a;</p> 
<p><img src=

box

为了探索这些数据,我们使用方法查看顶部的记录,并在 DataFrame 上调用方法以获取更多信息,例如有多少记录、有多少空记录或缺失记录,或各列的数据类型是什么。

To explore these data xff0c; we use methods to view top records xff0c; and to call on DataFrame to get more information xff0c; e.g. how many records, how many blank records or missing records xff0c; or what type of data is in each column.

我们可以看到列显示为对象。我们将其更改为日期时间以可视化这些数据。为此,我们使用方法,并将转换后的值分配回同一列——DataFrame。

We can see the columns as objects. We change them to date time to visualize the data. To this end, we use method & #xff0c; and assign the converted values back to the same column, DataFrame.

以下屏幕截图描述了比特币的日期格式:

The following screenshot depicts the date format of Bitcoin xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

)</p

将 DataFrame 的索引设置为列,并删除列作为单独的列。执行此步骤以利用 pandas 的时间序列功能。

Sets the DataFrame index to column & #xff0c; and removes the column as a separate column. Executes this step to use the time series function for pandas.

现在,通过在 DataFrame 上调用和来再次检查是否发生了更改。

& #xff0c; Checks if changes have occurred again by calling and calling on DataFrame.

以下屏幕截图显示了特定日期范围内的比特币:

The screenshot below shows bitcoin #xff1a within a given date range;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

Share chain control mechanism possible, suggested that the image be saved and sent directly up

现在我们准备从这些数据创建图表。在 DataFrame 上调用方法,然后调用方法显示图表。

Now we're going to create a chart from these data. Call method & #xff0c on DataFrame; then call method to display the chart.

它显示了已经在我们有记录的时间段内挖出的比特币总数。

It shows the total number of bitcoins that have been excavated within the time period we have recorded.

以下截图描述了前述数据的图表:

The following screenshot depicts the chart of the aforementioned data xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

 image transfer of the chain of origin may fail, and it is suggested that the image be saved and sent directly up to / /></p> 
 
<p>让我们看另一个例子。在这里,我们正在查看我们读入数据的区块数据的交易:</p><p>Let's see another example. Here's #xff0c; we're looking at the transactions of the block data we read the data #xff1a;</p> 
<p><img src=

</p

最初,我们使用和方法对这些数据进行可视化探索,如下截图所示:

Initially xff0c; we used and used methods to visualize the data xff0c; xff1a as shown in the screenshot below;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

chain

接下来,我们清理、转换和重塑数据,如下截图所示:

Next xff0c; we clean, convert and reconstruct data xff0c; xff1a as shown in the screenshot below;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

Ears chain transfer mechanism, possibly from the source station, suggesting that the image be preserved and directly uploaded

最后,我们将在区块数据中可视化我们的交易,如下截图所示:

Finally xff0c; we will visualize our transactions in block data xff0c; xff1a as shown in the screenshot below;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

 outward-chain image transfer failure at the source station, possibly involving a chain-control mechanism, and it is recommended that the image be preserved and sent directly

同样,还有另一个例子,我们应该看一下关于显示挖矿难度的数据。挖矿数据的步骤如下:

Also xff0c; there's another example xff0c; we should look at the data on the difficulty of mining. The steps for mining data are as follows xff1a;

  1. 读取数据,如下截图所示:

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

</p> 
<ol><li>探索数据,如下截图所示:</li></ol> 
<p><img src=

chain

  1. 清理数据,如下截图所示:

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

</p> 
<ol><li>最后,可视化数据,如下截图所示:</li></ol> 
<p><img src=

box

我们可以看到多年来挖矿难度逐渐增加,并呈上升趋势。这些只是交易图表的几个例子。比特币和区块链生态系统中还有很多其他可供您探索的数据。

These are just a few examples of trade charts. There are a lot of other data in Bitcoin and block chain ecosystems that you can explore.

在下一个模块中,我们将学习如何收集和分析比特币骰子游戏数据。

In the next module xff0c; we will learn how to collect and analyse bitcoin dice game data.

在本节中,我们将查看来自骰子游戏门户的数据,从 API 中读取数据,并使用将其转换为表格格式。我们还将导出数据并找到需要清理的内容。我们将清理、操作和重塑数据,使其准备好进行分析,最后,我们将从干净的数据中绘制一个简单的图表。

In this section xff0c; we will look at data from the dice game portal xff0c; read data from API xff0c; and use it to convert to table format. We will also export data and find what needs to be cleaned up. We will clean, operate and reshape data xff0c; prepare them for analysis xff0c; last xff0c; and we will draw a simple chart from clean data.

用户可以从 MegaDice.com 上的 API 链接探索骰子游戏数据,该数据可从网站的 API 链接获取。

Users can explore dice game data from API links on MegaDice.com & #xff0c; this data can be obtained from API links on the website .

我们将使用方法从 MegaDice API 链接中读取个人赢家历史数据。我们从这些数据创建了一个名为的,并调用方法来查看这些数据的样子。

We will use the method to read individual winner history data from the MegaDice API link. From this data we create a xff0c; and the method to look at the data.

以下截图中的代码显示了 的创建:

The code in the following screenshot shows the creation of xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

box

我们导入的数据有 703 列,其中大部分是个别日期。我们将删除最后一列,这不是实际数据的一部分,也不应该存在。该列显示在以下截图中:

The data we import are 703 columns & #xff0c; most of them are individual dates. We will delete the last column & #xff0c; this is not part of the actual data & #xff0c; nor should it exist. This column is shown in the following screenshot & #xff1a;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

)

由于列太多,行太少,我们希望将列变成行,其中每个状态都有一行记录。为了执行此操作,我们需要将列翻转为行,反之亦然。为此,我们需要执行以下步骤:

Because there are too many rows xff0c; too few rows xff0c; we want to turn the column into row xff0c; each of these states is recorded in a row. For this operation xff0c; we need to turn the column to row xff0c; and vice versa. For this purpose xff0c; we need to implement the following steps xff1a;

  1. 首先,我们重置索引,以便将当前索引作为另一列引入。当我们翻转时,此列的值将成为列名。使用方法确认,如下截图所示:

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

Image

  1. 接下来,使用称为或转置的方法翻转 DataFrame,如下截图所示:

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

)</p

  1. 现在,在以下截图中,我们可以看到我们的行索引已成为日期,我们之前的行已成为列:

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

s

我们已经得到了想要的列和行,但还有一些其他事情需要做。我们希望日期值以日期时间格式显示,但目前它是文本格式。然而,数据框的转置已经将日期值更改为索引。我们需要首先使用方法将它们转换为列,如下面的屏幕截图所示:

We've already got the desired columns and rows #xff0c; but there are other things to do. We want date values to be displayed in date time format xff0c; but it is currently text format. xff0c; the conversion of data boxes has changed date values to indexes. We need to first use the method to convert them to column xff0c; see xff1a in screen screenshots below;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

image

现在我们可以将这些文本数据转换为正确的日期时间格式,如下面的屏幕截图所示:

Now we can convert these text data into the correct date time format xff0c; the screen screen screen displays xff1a below;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

box

调用“info()”方法来确认这一点。我们在适当的日期时间格式中有了新的列“日期”。日期值需要以文本格式显示在列名索引中,如下面的屏幕截图所示:

Call info() to confirm this. We have a new column, Date, in the appropriate date time format. The date value needs to be displayed in text format in the list index & #xff0c; see xff1a on screen screen below;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

我们将把索引设置回适当的“日期”列,并将“日期”列作为单独的列删除,如下面的屏幕截图所示:

We will set the index back to the appropriate “date” column xff0c; and remove xff0c from the “date” column as a separate column; see xff1a in the screen screenshot below;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

)

现在,我们已经正确地在“日期”字段上建立了数据框的索引:

xff0c; we have correctly created a data frame index xff1a on the “date” field;

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

</p> 
<p>使用“plot()”方法绘制这些数据的示例图,并使用“plt.show()”方法显示,如下面的屏幕截图所示:</p><p>An illustrative map of these data xff0c using the

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

s

现在,这些数据可以用作时间序列函数,或者可以为不同日期子集可视化多个块等。

xff0c; these data can be used as a time sequence function xff0c; or they can visualize multiple blocks for different date subsets, etc.

在本章中,我们学习了如何准备数据分析的设置。我们看到了如何获取、读取和清理价格数据。我们还学习了如何探索、操作和可视化清理后的数据。

In this chapter xff0c; we learn how to prepare data analysis settings. We see how to get, read and clean price data. We also learn how to explore, operate and visualize post-cleaning data.

我们还探索了一些比特币和区块链图表,我们可以创建。我们学习了从哪里获取相关数据,并在 Jupyter Notebook 中读取了这些数据并导入了必要的模块。我们清理和操作了这些数据,最后,我们从这些数据和笔记本中创建了图表,但没有使用 Python。

We also explored some bitcoin and block chain charts & #xff0c; we can create. We learned where to get the relevant data & #xff0c; and we read the data in Jupyter Notebook and imported the necessary modules. We cleaned and operated the data & xff0c; xff0c; we created the chart xff0c from these data and notebooks; but did not use Python.

我们还探索了来自骰子游戏门户的数据。我们添加了来自 API 的数据,并使用 pandas 将其转换为表格格式。我们探索了数据,并找到了需要清理的内容。我们清理和操作了数据,并使其准备好进行分析。

We also explored data from the dice portal. We added data from API & #xff0c; we converted them to table format using pandas. We explored data & #xff0c; we found what needed to be cleaned up. We cleaned and operated data xff0c; and we prepared them for analysis.

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明

分享:

扫一扫在手机阅读、分享本文

发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • 美国可以使用什么加密货币交易所_前10名比特币交易平台名单

    美国可以使用什么加密货币交易所_前10名比特币交易平台名单
    美国可以使用什么加密货币交易所?What is an encrypted currency exchange that the United States can use?随着加密货币的普及,加密货币交易所也越来越多。对于美国的加密货币交易者而言,选择一个可靠、安全且易于使用的交易所是十分重要的事情。那么,美国可以使用哪些加密货币交易所呢?以下是前10名比特币交易平台名单:The choice of a reliable, secure, and easy-to-use...
  • 2017比特币已经挖出,比特币是什么?

    2017比特币已经挖出,比特币是什么?
    20 17比特币已经挖出了目录。20 17比特币被挖出来了。比特币是什么?比特币在20 17达到挖矿上限。在20 17中,比特币达到了挖矿上限,这意味着比特币的总数达到了2 1 100,000。比特币挖矿会越来越少。由于比特币挖矿的奖励每四年减半一次,未来比特币挖矿的数量将减少,比特币的价格可能会上涨。影响比特币市场的主要因素。除了挖矿上限和奖励减半之外,比特币市场还受到供需、投资者情绪和监管政策等因素的影响。比特币的未来前景。随着全球对比特币的认知度越来越高,比特币的前景仍...
  • 2015年宝马3系二手车价格多少钱

    2015年宝马3系二手车价格多少钱
    爱你一生不变心6558 2022-04-28 13:20:03 二手车能不能买主要看车况,如果车况好就可以考虑,车况不好价格再低也别考虑,像2015款宝马3系目前行情价是在18.32万这样,如果低...
  • Coinbase:财富100强企业过去一年的Web3采用率增长39%

    Coinbase:财富100强企业过去一年的Web3采用率增长39%
    随着比特币、以太坊等主流加密货币在web2世界的认可度变得越来越高,许多web2传统公司也积极拥抱web3,加速采用和开发区块链产品的速度和应用层面。With ˂a style= "max-width": 90%" href=https://m.php.cn/zt/21172.html" target="_blank" bitcoin, ˂a style="color:#f60; text-decoration: unde...
  • 区块链技术原理(转载)

    区块链技术原理(转载)
    转自:https://cloud.tencent.com/developer/article/1838661From: https://clud.tencent.com/development/article/1838661 本文主要是对区块链进行概念分析和组成技术解析,从哈希运算、数字签名、共识算法、智能合约、P2P网络等技术在区块链中的应用进行综合分析This paper focuses on conceptual analysis and technical com...
标签列表