This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def keep_decimal(origin_num, places): | |
| num_x, num_y = str(origin_num).split('.') | |
| if len(num_y) > places: | |
| num = float(num_x + '.' + num_y[0:places]) | |
| else: | |
| return origin_num | |
| return num |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if [ -d ~/.pip ]; | |
| then | |
| echo "~/.pip exist" | |
| else | |
| mkdir ~/.pip | |
| fi | |
| cd ~/.pip/ | |
| echo "[global]" > pip.conf | |
| echo "index-url = https://mirrors.aliyun.com/pypi/simple/" >> pip.conf | |
| echo "[install]" >> pip.conf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // check metamask exist | |
| if (typeof web3 !== 'undefined') { | |
| var currentProvider = web3.currentProvider; | |
| if(currentProvider){ | |
| if(currentProvider.isMetaMask){ | |
| console.log("currentProvider is Metamask"); | |
| if(currentProvider.isConnected()){ | |
| console.log("Connected Metamask"); | |
| var web3Instance = new Web3(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # pip3 install web3 | |
| from web3 import Web3 | |
| import json | |
| # network = "https://ropsten.infura.io/your_key" | |
| network = "http://127.0.0.1:8545" | |
| web3 = Web3(Web3.HTTPProvider(network)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # run pip3 install psutil | |
| import psutil | |
| #获取网卡名称和其ip地址,不包括回环 | |
| def get_netcard(): | |
| netcard_info = [] | |
| info = psutil.net_if_addrs() | |
| for k,v in info.items(): | |
| for item in v: | |
| if item[0] == 2 and not item[1]=='127.0.0.1': | |
| netcard_info.append((k,item[1])) |





