zeppelin連接數據源_使用開放源代碼合同(open-zeppelin)創建以太坊令牌

zeppelin連接數據源

by Danny

通過丹尼

使用開放源代碼合同(open-zeppelin)創建以太坊令牌 (Create an Ethereum token using open source contracts (open-zeppelin))

I want to show you that creating a best practice token is a simple process. To be honest, we are going to be doing some coding, but it won’t be much.

我想向您展示創建最佳實踐令牌是一個簡單的過程。 老實說,我們將要進行一些編碼,但是不會太多。

We’ll be using Solidity to create our Ethereum token. But don’t worry, there are a lot of open source libraries and contracts to help us in the process.

我們將使用Solidity創建我們的以太坊令牌。 但是不用擔心,有很多開源庫和合同可以在此過程中為我們提供幫助。

What we want is an ERC-20 compliant token. What that means is that the Ethereum developers have decided a set of functionalities that is necessary for your most common token usages today. There are other types of ERC standards, but we wont dive into it.

我們想要的是符合ERC-20的令牌。 這意味著以太坊開發人員已經決定了當今最常見的令牌使用所必需的一組功能。 還有其他類型的ERC標準,但我們不會深入探討。

Requirements:

要求:

  • Github

    Github
  • Terminal

    終奌站
  • NodeJS

    節點JS
  • NPM

    NPM
  • Metamask (For initial Account Creation)

    Metamask(用于初始帳戶創建)

Alright let’s start coding! The first thing we want to do is download truffleglobally. You can visit their repo at truffle and here’s the following snippet to install:

好吧,讓我們開始編碼! 我們要做的第一件事是全局下載truffle 。 您可以在松露處訪問他們的存儲庫,以下是要安裝的代碼段:

npm install -g truffle

*note: make sure you have the latest version of truffle if you installed this prior

*注意 :如果您事先安裝了最新版的松露,請確保已安裝

Truffle will handle the smart contract compilation, linking, and deployment for us. It’s a library that will make our lives easier for this demonstration.

松露將為我們處理智能合約的編譯,鏈接和部署。 這是一個圖書館,可以使我們的生活更加輕松。

Now we need to create a directory where our project will live. In my case I called it ethereum_token_tutorial.

現在,我們需要創建一個目錄,該目錄將用于我們的項目。 就我而言,我將其稱為ethereum_token_tutorial。

So we have two options here. Either you can clone the repo I have created by following this:

因此,我們在這里有兩個選擇。 您可以按照以下步驟克隆我創建的存儲庫:

git clone -b initial_step https://git@github.com/danieljoonlee/ethereum_token_tutorial.git

Or you can do this in your terminal inside of your new directory:

或者,您可以在新目錄內的終端中執行此操作:

truffle init

If you followed the second option of doing truffle init. The directory should look like this:

如果遵循第二種選擇,即truffle init 。 該目錄應如下所示:

etherem_token_tutorial|___contracts| |_____ConvertLib.sol| |_____MetaCoin.sol| |_____Migrations.sol|___migrations| |_____1_initial_migrations.js| |_____2_deploy_contracts.js|___test| |_____TestMetacoin.sol| |_____metacoin.js|___truffle.js

Go ahead and delete ConvertLib.sol , MetaCoin.sol , TestMetacoin.sol , metacoin.js.

繼續并刪除ConvertLib.solMetaCoin.solTestMetacoin.solmetacoin.js

So your directory should look like this now:

因此您的目錄現在應如下所示:

etherem_token_tutorial|___contracts| |_____Migrations.sol|___migrations| |_____1_initial_migrations.js| |_____2_deploy_contracts.js|___test|___truffle.js

Great. Now we’re moving. Truffle helps us compile smart contracts and deploy them. But we deleted our smart contract files other than the migrating helper. Don’t worry, this is where Open-Zeppelin comes in.

大。 現在我們要搬家了。 松露可幫助我們編譯和部署智能合約。 但是我們刪除了遷移助手以外的智能合約文件。 別擔心,這是Open-Zeppelin的用武之地。

Open-Zeppelin is an open source repo where you can find smart contracts with generally best practices, good test coverage, and most likely audited*.

Open-Zeppelin是一個開放源代碼回購,您可以在其中找到具有最佳實踐,良好的測試覆蓋率以及最有可能經過審計*的智能合約。

  • Audit is when you have professional developers review your smart contracts looking for any leaks, bugs, or possibilities of malicious attacks.

    審核是指讓專業開發人員查看您的智能合約,以查找任何泄漏,錯誤或惡意攻擊的可能性。

Here’s a link if you’re interested in smart contract attacks: Link

如果您對智能合約攻擊感興趣,請使用以下鏈接: 鏈接

For us to use any Open-Zeppelin contracts we need to install it into our repository:

為了讓我們使用任何Open-Zeppelin合同,我們需要將其安裝到我們的存儲庫中:

npm init -ynpm install -E zeppelin-solidity

We initialized a package.json with npm init -y. We also installed the package for using the Open-Zeppelin contracts.

我們使用npm init -y初始化了package.json。 我們還安裝了使用Open-Zeppelin合同的軟件包。

Okay, we’re going to write some Solidity. I did mention in the article earlier that this will not be much code and I wasn’t joking!

好的,我們將編寫一些Solidity。 我在前面的文章中確實提到過,這不會是太多代碼,而且我不是在開玩笑!

Create a new file in the contracts folder. In my case I named it TestToken.sol

contracts文件夾中創建一個新文件。 就我而言,我將其命名為TestToken.sol

Now your directory should look like this:

現在您的目錄應如下所示:

etherem_token_tutorial|___contracts| |_____Migrations.sol| |_____TestToken.sol***(this one is new)|___migrations| |_____1_initial_migrations.js| |_____2_deploy_contracts.js|___test|___truffle.js

In TestToken.sol we need to have the following code:

TestToken.sol我們需要以下代碼:

// TestToken.solpragma solidity ^0.4.18;
import "zeppelin-solidity/contracts/token/ERC20/MintableToken.sol";
contract TestToken is MintableToken {    string public constant name = "Test Token";    string public constant symbol = "TT";    uint8 public constant decimals = 18;}

Let’s break this down since it’s quite a bit , even though it’s only a few lines of code.

讓我們分解一下,因為它雖然很多,但只有幾行代碼。

pragma solidity ^0.4.18;

pragma solidity ^0.4.18;

It is required at the top of the file because it specifies the version of Solidity we’re using.

在文件頂部是必需的,因為它指定了我們正在使用的Solidity版本。

import "zeppelin-solidity/contracts/token/ERC20/MintableToken.sol";

The above code snippet is why Open-Zeppelin is so useful. If you know how inheritance works, our contract is inheriting from MintableToken. If you don’t know how inheritance works, MintableToken has a lot of functionalities saved in inMintableToken.sol. We can use these functionalities to create our token. If you visit this MintableToken you’ll notice a ton of functions and even more inheritance. It can be a bit of a rabbit hole, but for this demonstration purpose, I want us to release a token into the testnet.

上面的代碼段是為什么Open-Zeppelin如此有用的原因。 如果您知道繼承的工作原理,那么我們的合同就是從MintableToken繼承的。 如果您不知道繼承的工作原理,則MintableToken在inMintableToken.sol中保存了很多功能。 我們可以使用這些功能來創建令牌。 如果您訪問此MintableToken,您會注意到大量的函數甚至更多的繼承。 這可能有點麻煩,但是出于演示目的,我希望我們將令牌釋放到測試網中。

For us, Mintable let’s us create as many tokens as we want, so we won’t be starting with an initial supply. In my next article, we’ll create a nodejs service that will create new tokens, and handle other ERC-20 standard functionalities.

對于我們來說,Mintable讓我們創建所需數量的令牌,因此我們不會從初始供應開始。 在我的下一篇文章中,我們將創建一個nodejs服務,該服務將創建新令牌并處理其他ERC-20標準功能。

The next bit of code:

下一段代碼:

contract TestToken is MintableToken {    string public constant name = "Test Token";    string public constant symbol = "TT";    uint8 public constant decimals = 18;}

This is where we can customize the token. In my case, I named mine “Test Token”, with the symbol “TT”, and decimals of 18. But why 18 decimals?

這是我們可以自定義令牌的地方。 在我的情況下,我將我的“ Test Token”命名為“ TT”,十進制數為18。但是為什么要18十進制數呢?

Decimals of 18 is fairly standard in the community. So if we have one test token it can potentially look like this 1.111111111111111111.

在社區中,小數點18是相當標準的。 因此,如果我們有一個測試令牌,它可能看起來像這樣1.111111111111111111111。

Whelp. That’s all the Solidity coding we need to do for this token. We inherit all the main functionalities for a standardized ERC 20 token from Open-Zeppelin. After that we need to set our constants for the name, symbol, and decimals.

仔。 這就是我們需要為此令牌執行的所有Solidity編碼。 我們繼承了Open-Zeppelin標準化ERC 20令牌的所有主要功能。 之后,我們需要為名稱,符號和小數設置常量。

Before we forget, we should create a Metamask account and get it funded with testnet ethereum.

在忘記之前,我們應該創建一個Metamask帳戶,并使用testnet以太坊為其提供資金。

Go ahead and search MetaMask extension for Chrome, or follow this link

繼續并搜索MetaMask于Chrome的MetaMask擴展程序,或點擊此鏈接

After you install MetaMask you should see a series of steps. You can read through like terms of service. Eventually you’ll reach:

安裝MetaMask后,您應該會看到一系列步驟。 您可以閱讀類似的服務條款。 最終您將達到:

Input your password and confirm that password. On clicking create, you will see another screen.

輸入您的密碼并確認該密碼。 單擊創建時,您將看到另一個屏幕。

Make sure to save your seed words or copy them down into a text file. We will need those seed words to deploy the token onto the testnet.

確保保存您的種子詞或將其復制到文本文件中。 我們將需要這些種子詞來將令牌部署到測試網上。

Also more important is to change your test from Mainnet Test Net to Ropsten Test net. It’s on the top left of your MetaMask tab. Here is the drop down:

同樣重要的是將您的測試從Mainnet測試網更改為Ropsten測試網。 它在您的MetaMask標簽的左上方。 這是下拉列表:

The reason we’re using Ropsten Test Network is because it’s the closest testnet/implementation of the Main Ethereum Network.

我們使用Ropsten測試網絡的原因是因為它是以太坊主網絡最接近的測試網/實現。

Next you will need to copy your address to clipboard from the ... menu like so:

接下來,您需要將地址從...菜單復制到剪貼板,如下所示:

You should have an address similar to this one copied to your clipboard:

您應該將與該地址相似的地址復制到剪貼板:

address: 0x8EeF4Fe428F8E56d2202170A0bEf62AAc93989dE

This is the address from which we’re going to deploy our token contract. Now one thing you need to know about deploying contracts is that they cost Ethereum, to be specific Gas. We’re going to need to get some testnet Ethereum into our accounts.

這是我們將用來部署令牌合約的地址。 現在,您需要了解的有關部署合同的一件事是,它們要花費以太坊,具體來說就是Gas。 我們將需要在賬戶中加入一些以太坊測試網。

Now that you have your address go to this Ropsten faucet link:

現在您有了地址,請轉到以下Ropsten水龍頭鏈接:

Ethernet FaucetEdit descriptionfaucet.ropsten.be

以太網水龍頭 編輯描述 faucet.ropsten.be

Copy and paste your address and soon you should have 1 Ethereum in your MetaMask wallet for your address.

復制并粘貼您的地址,不久您的MetaMask錢包中應該有1個以太坊作為您的地址。

Just one more thing before we start coding our deployment process! We’re going to use a free API called Infura.io:

在開始對部署過程進行編碼之前,還有一件事情! 我們將使用一個名為Infura.io的免費API:

Infura — Scalable Blockchain InfrastructureSecure, reliable, and scalable access to Ethereum APIs and IPFS gateways.infura.io

Infura —可擴展的區塊鏈基礎架構 對以太坊API和IPFS網關的安全,可靠和可擴展的訪問。 信息

Sign up for their services. You should get an email from them or be redirected to a site with your API Key. The one we want specifically is from the Ropsten Network.

注冊他們的服務。 您應該從他們那里收到電子郵件,或使用API??密鑰將其重定向到網站。 我們特別想要的是來自Ropsten網絡的產品。

Test Ethereum Network (Ropsten)https://ropsten.infura.io/API_KEY

Copy your API_KEY.

復制您的API_KEY。

Almost there! Now let’s start working on our deployment. Let’s head back in our code.

差不多了! 現在,讓我們開始進行部署。 讓我們回到我們的代碼中。

First things first, let’s talk about security. Create a new file in your root directory called .env. Your file structure should now look like this:

首先,讓我們談談安全性。 在您的根目錄中創建一個名為.env的新文件。 您的文件結構現在應如下所示:

etherem_token_tutorial|___contracts| |_____Migrations.sol| |_____TestToken.sol|___migrations| |_____1_initial_migrations.js| |_____2_deploy_contracts.js|___test|___truffle.js|___.env**(new file)

Inside your .env file lets add some environmental variables (these are variables that you can access anywhere in your code directory)

.env文件中,可以添加一些環境變量(這些變量可以在代碼目錄中的任何位置訪問)

//.env fileINFURA_API_KEY=API_KEYMNENOMIC=MNEOMIC_FROM_METAMASK

First add your API_KEY you copied into the file.

首先將您復制的API_KEY添加到文件中。

Remember the Mneomic(seed words) from initializing Metamask chrome extension? We’re going to need that now to deploy the contracts from. If you downloaded or wrote down your Mneomic, now write them down in your .env file MNENOMIC=SOME KEY PHRASE YOU DONT WANT THE PUBLIC TO KNOW.

還記得初始化Metamask chrome擴展時的Mneomic(種子詞)嗎? 我們現在需要從中部署合同。 如果您下載或記下了Mneomic,請現在將其記入.env文件中MNENOMIC=SOME KEY PHRASE YOU DONT WANT THE PUBLIC TO KNOW..env MNENOMIC=SOME KEY PHRASE YOU DONT WANT THE PUBLIC TO KNOW.

IMPORTANT***

重要***

We added a .env file!!! We need to add a .gitignore file now to avoid adding the .env to a public repository if you ever decide to make the code public!

我們添加了.env文件!!! 如果您決定公開代碼,我們現在需要添加.gitignore文件,以避免將.env添加到公共存儲庫中!

Create a .gitignore file in the same directory as your .env. Now it should look like this:

在與.env相同的目錄中創建一個.gitignore文件。 現在看起來應該像這樣:

etherem_token_tutorial|___contracts| |_____Migrations.sol| |_____TestToken.sol|___migrations| |_____1_initial_migrations.js| |_____2_deploy_contracts.js|___test|___truffle.js|___.env|___.gitignore**(newfile)

Inside your .gitignore file:

在您的.gitignore文件中:

// .gitignorenode_modules/build/.env

We want to ignore node_modules/ because when we do npm install it will download packages from our package.json. We want to ignore buildbecause later on when we run a script, it will create that directory for us automatically. We also want to ignore .env because it has private information we don’t want to release to the public.

我們想忽略node_modules/因為在進行npm install ,它將從package.json下載軟件包。 我們想忽略build因為稍后運行腳本時,它將自動為我們創建該目錄。 我們也想忽略.env因為它包含我們不希望向公眾發布的私人信息。

Great! Over in our terminal we need to add two more modules.

大! 在我們的終端中,我們需要再添加兩個模塊。

npm install --save dotenv truffle-hdwallet-provider

Since we’re putting in private information, we need a way to access those variables from .env, and the dotenv package will help us.

由于我們要輸入私人信息,因此我們需要一種從.env訪問這些變量的.env ,而dotenv軟件包將為我們提供幫助。

The second package, truffle-hdwallet-provider is a wallet enabled provider. Without this, we would need to download all the blocks or use a light wallet to make new transactions in the Ethereum network. With the wallet provider and Infura API. We can deploy instantly, also bypassing painful processes.

第二個軟件包truffle-hdwallet-provider是啟用了錢包的提供程序。 否則,我們將需要下載所有區塊或使用輕錢包在以太坊網絡中進行新交易。 使用錢包提供商和Infura API。 我們可以立即部署,也可以繞過繁瑣的過程。

Over in the truffle.js in our root directory, we need to modify some configurations.

在根目錄的truffle.js中,我們需要修改一些配置。

// truffle.jsrequire('dotenv').config();const HDWalletProvider = require("truffle-hdwallet-provider");
module.exports = {  networks: {    development: {      host: "localhost",      port: 7545,      gas: 6500000,      network_id: "5777"    },    ropsten: {        provider: new HDWalletProvider(process.env.MNENOMIC, "https://ropsten.infura.io/" + process.env.INFURA_API_KEY),        network_id: 3,        gas: 4500000    },  }};

The first line indicates we want to use the .env variables in this repo. Generally in most apps, you only need to require this once in the starting config file.

第一行表明我們要在此.env中使用.env變量。 通常,在大多數應用中,您只需在啟動配置文件中要求一次。

Most of this is boilerplate. Main section we want to focus on is the ropsten network.

其中大部分是樣板。 我們要關注的主要部分是繩索網絡。

ropsten: {        provider: new HDWalletProvider(process.env.MNENOMIC, "https://ropsten.infura.io/" + process.env.INFURA_API_KEY),        network_id: 3,        gas: 4500000    },

The provider is our network. In our case, we want to deploy our token into the Ropsten network. Using the HDWalletProvider we pass in two arguments, process.env.MNENOMIC, "https://ropsten.infura.io/" + process.env.INFURA_API_KEY. We access our .env variables by referencing process.env.VARIABLE_NAME_IN_ENV.

提供者是我們的網絡。 在我們的案例中,我們希望將令牌部署到Ropsten網絡中。 使用HDWalletProvider我們傳入兩個參數process.env.MNENOMIC, "https://ropsten.infura.io/" + process.env.INFURA_API_KEY 。 我們通過引用process.env.VARIABLE_NAME_IN_ENV訪問我們的.env變量。

We set the network_id: 3 because that represents Ropsten. 1 is the main Ethereum net and 2 is an old testnet.

我們將network_id: 3設置為network_id: 3因為它表示Ropsten。 1是主要的以太坊網絡, 2是舊的測試網。

Lastly, we set gas: 4500000, which is why we needed the Ethereum originally. We use gas/ethereum any time we need to modify/add something in the Ethereum Network.

最后,我們將gas: 4500000設置為gas: 4500000 ,這就是為什么我們最初需要以太坊的原因。 每當需要在以太坊網絡中修改/添加某些內容時,我們都會使用gas/ethereum

Alright, onto the last step before deployment!

好了,部署前的最后一步!

Over in our migrations/2_deploy_contract.js, we need to make some modifications for our contract.

在我們的migrations/2_deploy_contract.js ,我們需要對合同進行一些修改。

// 2_deploy_contract.js
const TestToken = artifacts.require("./TestToken.sol");
module.exports = function(deployer) {  deployer.deploy(TestToken);};

If you named your token contract file something else. You need to replace the TestToken.sol to whatever file you named it.

如果您將令牌合同文件命名為其他名稱。 您需要將TestToken.sol替換為您命名的任何文件。

truffle compile

This should create a new folder in your directory:

這應該在您的目錄中創建一個新文件夾:

etherem_token_tutorial|___build| |_____contracts|    |_____BasicToken.json|    |_____ERC20.json|    |_____ERC20Basic.json|    |_____Migrations.json|    |_____MintableToken.json|    |_____Ownable.json|    |_____SafeMath.json|    |_____StandardToken.json|    |_____TestToken.json|___contracts| |_____Migrations.sol| |_____TestToken.sol|___migrations| |_____1_initial_migrations.js| |_____2_deploy_contracts.js|___test|___truffle.js|___.env|___.gitignore**(newfile)

In our build folder, we have a bunch of contracts we inherited from the Open-Zeppelin library. If you’d like to know more about ERC-20 standards I’d check out the wiki. If there’s enough people asking for it I can make another blog post on it. For now here’s the link to the wiki.

在我們的build文件夾中,我們有一堆繼承自Open-Zeppelin庫的合同。 如果您想了解有關ERC-20標準的更多信息,請查看Wiki。 如果有足夠的人要求它,我可以在上面發表另一篇博客文章。 現在,這里是Wiki的鏈接。

Here comes the moment of truth. Now we need to deploy the contracts into the Ropsten network. Enter the following line in your terminal:

關鍵時刻到了。 現在,我們需要將合??同部署到Ropsten網絡中。 在終端中輸入以下行:

truffle migrate --network ropsten

You should get a series of lines in your terminal like:

您應該在終端中看到以下幾行:

Using network 'ropsten'.
Running migration: 1_initial_migration.js  Deploying Migrations...  ... 0x7494ee96ad7db4a560b6f3169e0666c3938f9f54208f7972ab902feb049a7f68  Migrations: 0x254466c5b09f141ce1f93689db6257b92133f51aSaving successful migration to network...  ... 0xd6bc06b3bce3d15dee4b733e5d4b09f0adb8f93f75ad980bad078484641d36e5Saving artifacts...Running migration: 2_deploy_contracts.js  Deploying TestToken...  ... 0x7e5c1b37f1e509aea59cd297417efe93eb49fdab2c72fa5c37dd2c63a3ba67b7  TestToken: 0x02ec6cbd89d3a435f8805e60e2703ef6d3147f96Saving successful migration to network...  ... 0x2fd6d699295d371ffd24aed815a13c5a44e01b62ca7dc6c9c24e2014b088a34eSaving artifacts...

This will take some time. Once it’s fully deployed copy the last txid. In my case:

這將需要一些時間。 完全部署后,復制最后一個txid。 就我而言:

0x2fd6d699295d371ffd24aed815a13c5a44e01b62ca7dc6c9c24e2014b088a34e

This will have an address to your token contract. Here is a link to my txid:

這將有您的令牌合同的地址。 這是我的txid的鏈接:

Ropsten Transaction 0x2fd6d699295d371ffd24aed815a13c5a44e01b62ca7dc6c9c24e2014b088a34eRopsten (ETH) detailed transaction info for 0x2fd6d699295d371ffd24aed815a13c5a44e01b62ca7dc6c9c24e2014b088a34eropsten.etherscan.io

Ropsten交易0x2fd6d699295d371ffd24aed815a13c5a44e01b62ca7dc6c9c24e2014b088a34e Ropsten(ETH)詳細的交易信息(0x2fd6d699295d371ffd24aed815a13c5a44e01b62ca7dc6c9c24eropstenio

Which has an address to the contract itself:

其中包含合同本身的地址:

Ropsten Accounts, Address and ContractsThe Ethereum BlockChain Explorer, API and Analytics Platformropsten.etherscan.io

Ropsten賬戶,地址和合約 以太坊區塊鏈瀏覽器,API和分析平臺 ropsten.etherscan.io

You can get the completed github repo here.

您可以在此處獲取完整的github存儲庫。

This part one of a series of creating a token and interacting with it. In the next blog we will create a simple node microservice. We will use this service to call various functions on your token smart contract, such as minting new tokens, transferring, etc.

創建令牌并與之交互的一系列步驟之一。 在下一個博客中,我們將創建一個簡單的節點微服務。 我們將使用此服務在您的令牌智能合約上調用各種功能,例如鑄造新令牌,轉讓等。

If you find any mistakes or typos please let me know! Also I’m always looking for exciting projects in the blockchain space.

如果您發現任何錯誤或錯別字,請告訴我! 另外,我一直在尋找在區塊鏈領域令人興奮的項目。

If you found this helpful and feel like buying me a beer:

如果您覺得這有幫助,并且想給我買啤酒:

BTC: 3Kxz6zPweuiaVG28W78pX9DoEZVkLhH4nT

BTC:3Kxz6zPweuiaVG28W78pX9DoEZVkLhH4nT

BCH: qqwusc2peyvlh3wgl0tpt3ll4ug9zujfvy9586tgd4

BCH:qqwusc2peyvlh3wgl0tpt3ll4ug9zujfvy9586tgd4

ETH: 0x96Ee87e22D899BDc27EAD4fE3FCA8e9F39176B4C

ETH:0x96Ee87e22D899BDc27EAD4fE3FCA8e9F39176B4C

LTC: MDhqUBtGgVZrDG7TYzzyK2a2b99sHyHaQQ

LTC:MDhqUBtGgVZrDG7TYzzyK2a2b99sHyHaQQ

翻譯自: https://www.freecodecamp.org/news/create-an-ethereum-token-using-open-source-contracts-open-zeppelin-1e132e6233ed/

zeppelin連接數據源

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/394689.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/394689.shtml
英文地址,請注明出處:http://en.pswp.cn/news/394689.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

python不是內部文件_已安裝python,但是出現‘python’不是內部或外部命令,也不是可運行的程序或批處理文件。...

解決方法: 1.打開python shell查看你的python安裝路徑(黃色標注) >>> import sys >>> sys.path [, C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python37\\Lib\\idlelib, C:\\Users\\Administrator\\App…

使用canvas繪制時鐘

使用canvas繪制時鐘 什么使canvas呢&#xff1f;HTML5 <canvas> 元素用于圖形的繪制&#xff0c;通過腳本 (通常是JavaScript)來完成。<canvas> 標簽只是圖形容器&#xff0c;所以我們必須使用腳本來繪制圖形。通過它可以繪制路徑,盒、圓、字符以及添加圖像等等。 …

Visual Studio 2017創建XAML文件

Visual Studio 2017創建XAML文件在Visual Stuido 2015中&#xff0c;在已經創建好的項目中添加XAML文件&#xff0c;只要右擊項目&#xff0c;單擊“添加”|“新建項”命令&#xff0c;然后從“添加新項”對話框中&#xff0c;選擇“Cross-Platform”|“Forms Xaml Page”選項即…

android 安裝assets中的apk,如何安裝assets下apk,附源碼(原創)

publicstaticvoidInstall(Context ctx, String strLocalFile) {Intent intentInstallnewIntent();String apkPath"/data/data/"ctx.getPackageName()"/files";String apkName"yuan.apk";File filenewFile(apkPath, apkName);try{//assets下對于超…

FtpWebRequest.UsePassive屬性:設置FTP工作模式

默認值&#xff1a;true&#xff0c;被動模式 PASV&#xff08;被動&#xff09;方式的連接過程是&#xff1a;客戶端向服務器的FTP端口&#xff08;默認是21&#xff09;發送連接請求&#xff0c;服務器接受連接&#xff0c;建立一條命令鏈路。 當需要傳送數據時&#xff0c; …

angular面試題及答案_關于最流行的Angular問題的StackOverflow上的48個答案

angular面試題及答案by Shlomi Levi通過Shlomi Levi 關于最流行的Angular問題的StackOverflow上的48個答案 (48 answers on StackOverflow to the most popular Angular questions) I gathered the most common questions and answers from Stackoverflow. These questions we…

c++分治法求最大最小值實現_最優化計算與matlab實現(12)——非線性最小二乘優化問題——G-N法...

參考資料《精通MATLAB最優化計算&#xff08;第二版&#xff09;》編程工具Matlab 2019a目錄石中居士&#xff1a;最優化計算與Matlab實現——目錄?zhuanlan.zhihu.com非線性最小二乘優化問題非線性最小二乘優化也叫無約束極小平方和函數問題&#xff0c;它是如下無約束極小問…

win7 IIS7環境下部署PHP 7.0

最近在本機電腦win7 II7環境下部署PHP 7.0遇到一些問題&#xff0c;將之記錄下來 簡要步驟如下&#xff1a; 1、到php官網下載php&#xff0c;由于是IIS環境要下載非線程安全的版本&#xff0c;我下載的是7.0.13 2、解壓到本地文件目錄下 3、通過控制臺進入到php文件目錄&#…

《Oracle高性能自動化運維》一一3.3 Redo產生場景

3.3 Redo產生場景我們知道&#xff0c;Oracle Redo是以條目&#xff08;Redo Entries/Records&#xff09;的形式記錄數據庫的所有更改操作&#xff08;OP&#xff09;。更改操作主要包括&#xff1a;數據庫物理文件更改&#xff1a;主要指的是數據庫物理文件的增減等操作&…

智能算法(GA、DBO等)求解零空閑流水車間調度問題(NIFSP)

先做一個聲明&#xff1a;文章是由我的個人公眾號中的推送直接復制粘貼而來&#xff0c;因此對智能優化算法感興趣的朋友&#xff0c;可關注我的個人公眾號&#xff1a;啟發式算法討論。我會不定期在公眾號里分享不同的智能優化算法&#xff0c;經典的&#xff0c;或者是近幾年…

《構建之法》讀后感 二

個人感受部分&#xff1a; 01. 過去的我對自己的職業沒有一個規劃&#xff0c;認為讀大學就是拿畢業證&#xff0c;至于以后找到什么樣的工作從來沒有考慮過。在拿到一個軟件作業時&#xff0c;總是在設計階段就把它想得特別完美&#xff0c;想讓他沒有任何出錯的做出來&#x…

android 簡單實現圓角,Android 實現圓角圖片的簡單實例

Android 實現圓角圖片的簡單實例實現效果圖&#xff1a;本來想在網上找個圓角的例子看一看&#xff0c;不盡人意啊&#xff0c;基本都是官方的Demo的那張原理圖&#xff0c;稍后會貼出。于是自己自定義了個View&#xff0c;實現圖片的圓角以及圓形效果。效果圖&#xff1a;Andr…

zookeeper介紹及集群的搭建(利用虛擬機)

ZooKeeper ?   ZooKeeper是一個分布式的&#xff0c;開放源碼&#xff08;apache&#xff09;的分布式應用程序協調服務&#xff0c;是Google的Chubby一個開源的實現&#xff0c;是Hadoop和Hbase、dubbox、kafka的重要組件。它主要用來解決分布式集群中應用系統的一致性問題…

pythondict初始化_利用defaultdict對字典進行全局初始化。

通常我們在操作字典時&#xff0c;如果讀取的鍵未被初始化&#xff0c;則會拋出KeyError的錯誤&#xff0c;這個是我們都很熟悉的。那么一般的解決方式是使用異常處理或者是調用字典的get方法來避免出現這個異常。 可以看到&#xff0c;這兩種寫法都比較繁瑣&#xff0c;第二種…

標準庫類型String

定義和初始化string對象 初始化string對象方式 string s1 默認初始化&#xff0c;s1是一個空串 string s2(s1) s2是s1的副本 string s2 s1 等價于s2(s1), s2是s1的副本 string s3("value") s3是字面值"value"的副本&#xff0c;除了字面值最后的那個…

輕量級數據庫中間件利器Sharding-JDBC深度解析(有彩蛋)

講師介紹張亮 當當架構部總監 負責分布式中間件和私有云平臺建設 目前主導開源項目&#xff1a;Elastic-Job及Sharding-JDBC 主題簡介&#xff1a; 1、關系型數據庫中間件核心功能介紹 2、Sharding-JDBC架構及內核解析 3、Sharding-JDBC未來展望 一、關系型數據庫中間件核心功…

python字典嵌套字典的情況下獲取某個key的value

最近在用python寫接口的測試程序&#xff0c;期間用到解析字典獲取某個key的value&#xff0c;由于多個接口返回的字典格式不是固定的并存在多層嵌套的情況。在字典的方法中也沒有找到可直接達到目的的方法(也可能是我對字典的方法了解的不深的緣故)&#xff0c;于是自己寫了個…

系統在此應用程序堆棧溢出_從部署我的第一個完整堆棧Web應用程序中學到的經驗教訓...

系統在此應用程序堆棧溢出by Will Abramson威爾艾布拉姆森(Will Abramson) 從部署我的第一個完整堆棧Web應用程序中學到的經驗教訓 (Lessons learned from deploying my first full-stack web application) I recently achieved one of my long-term goals: deploying my firs…

const 常量_條款03:盡可能使用const

const 允許你指定一個語義約束&#xff08;也就是指定一個“不該被改動”的對象&#xff09;&#xff0c;而編譯器會強制實施這項約束。1、const指針如果關鍵字const出現在星號左邊&#xff0c;表示被指物是常量&#xff1b;如果出現在星號右邊&#xff0c;表示指針自身是常量&…

javascript高級程序設計---js事件思維導圖

繪制思維軟件與平時用的筆記&#xff0c;以及導出功能&#xff0c;這三個問題綜合起來&#xff0c;于是我把思維導圖分開畫 1、js事件的基本概念 2、js事件的事件處理程序 3、js事件的事件對象 轉載于:https://www.cnblogs.com/Jamie1032797633/p/10567419.html