import random
import string
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
rpc_port = 18444
rpc_user = 'user3'
rpc_password = 'pass3'
def wallet_name(size):
generate_wallet = ''.join([random.choice(string.punctuation + string.ascii_letters)
for n in range(size)])
return generate_wallet
try:
rpc_connection = AuthServiceProxy("http://%s:%s@127.0.0.1:%s"%(rpc_user,rpc_password,rpc_port))
i=0
while i < 500:
wallet = wallet_name(20)
result = rpc_connection.createwallet(wallet)
i += 1
except Exception:
pass
我想要此代码尝试创建500个钱包,但它在2-3停止。如果我打印异常,它会给出一个与不正确的文件名或文件路径相关的错误,但是这个异常应该被忽略,并尝试使用下一个字符串创建wallet。
发布于 2021-03-23 04:02:35
当你甚至没有保存名字的时候,创建500个随机命名的钱包有什么意义呢?
for i in range(500):
wallet = wallet_name(20)
try:
result = rpc_connection.createwallet(wallet)
except:
pass
https://stackoverflow.com/questions/66757014
复制相似问题