# Python to Rust Code Convert

**URL:** <https://users.rust-lang.org/t/python-to-rust-code-convert/47935>\
**Category:** help\
**Created:** [August 27, 2020, 10:51pm UTC](https://users.rust-lang.org/t/python-to-rust-code-convert/47935 "2020-08-27T22:51:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrewz](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@Andrewz](https://users.rust-lang.org/u/Andrewz)\
**Post date:** [August 27, 2020, 10:51pm UTC](https://users.rust-lang.org/t/python-to-rust-code-convert/47935/1 "2020-08-27T22:51:12Z")

</div>

Hello, I tried to convert this python code to rust:

```rust
validfile = open('validated.txt', 'r')
    validinfo = validfile.read()
    validinfo = validinfo.split('\n')
    session = sessions.FuturesSession(max_workers=thread)
    refresh = []
    futures = []
    start_snipe = time.time()
for i in range(thread):
        alt_index = random.randint(0, len(validinfo) - 1)
        futures.append(session.post(f"https://api.mojang.com/user/profile/{validinfo[alt_index].rpartition(':')[(-1)].rpartition(':')[(-1)]}/name", headers={'Authorization': 'Bearer ' + validinfo[alt_index].rpartition(':')[0].rpartition(':')[(-1)]}, json={'name':TARGET, 'password':validinfo[alt_index].rpartition(':')[0].rpartition(':')[0].rpartition(':')[-1]}))

```

Tried for like 30 minutes, but I have no idea how it should look in Rust. Can anyone help me? I need it very clean code, simple and complex. How should I'll do it in the best way and next time I will know. Also some examples will help. Also, validated.txt it's spaced. Like [email@email.com](mailto:email@email.com):password:bearer

---

<div class="post-metadata">

**Author:** ![mburszley](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/mburszley/32/13944_2.png) [@mburszley](https://users.rust-lang.org/u/mburszley)\
**Post date:** [August 28, 2020, 1:08am UTC](https://users.rust-lang.org/t/python-to-rust-code-convert/47935/2 "2020-08-28T01:08:40Z")

</div>

It would help if you posted what you've tried so it can be helped. I doubt someone is going to come along and convert code for you for free.

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/system/32/51372_2.png) [@system](https://users.rust-lang.org/u/system)\
**Post date:** [November 26, 2020, 1:08am UTC](https://users.rust-lang.org/t/python-to-rust-code-convert/47935/3 "2020-11-26T01:08:57Z")

</div>

Closed on November 26, 2020, 1:08am UTC

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.
