删除打印的生成密码之间的空格

发布于 2025-01-20 21:56:32 字数 616 浏览 2 评论 0原文

我写了一个Python脚本来破解被遗忘帐户的密码。 但是,每次我打印一个密码时,“入侵/黑客入侵”与其他任何内容之间都有一个空间。

我怀疑空间字符在密码变量中。无论我做什么,我的IDE都不会让我在密码变量中的引号之间删除该空间。如何删除它?

这是代码:

while True:
   import random
   num ="12"
   ans = num + "-"
   ans2 = num + "/"
   ans3 = num + "_"
   length = 3
   password ="".join(random.sample(ans,length))
   password2 ="".join(random.sample(ans2,length))
   password3 ="".join(random.sample(ans3,length))
   print("Hacked",password)
   print("hacked",password)
   print("Hacked",password2)
   print("hacked",password2)
   print("Hacked",password3) 

I wrote a Python script to crack the password of forgotten accounts.
However, everytime I print a password, there is a space between "Hacked/hacked" and whatever else.

I suspect that the space character is somewhere in the password variables. No matter what I do, my IDE won't let me remove that space between the quotes in the password variable. How can I remove it?

Here's the code:

while True:
   import random
   num ="12"
   ans = num + "-"
   ans2 = num + "/"
   ans3 = num + "_"
   length = 3
   password ="".join(random.sample(ans,length))
   password2 ="".join(random.sample(ans2,length))
   password3 ="".join(random.sample(ans3,length))
   print("Hacked",password)
   print("hacked",password)
   print("Hacked",password2)
   print("hacked",password2)
   print("Hacked",password3) 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

命硬 2025-01-27 21:56:32

解决这个问题的几种方法:

print(f'HACKED{var}')
print('HACKED'+var)

Several ways to solve this:

print(f'HACKED{var}')
print('HACKED'+var)
鸠魁 2025-01-27 21:56:32

默认情况下,print()将每个参数传递到一个空间中。您可以通过指定sep参数(在这种情况下,要将空字符串用作分隔器)来覆盖此问题。例如,您可以执行以下操作:

print("Hacked", password, sep="")

By default, print() separates each argument passed to it with a space. You can override this by specifying the sep parameter (in this case, you want to use the empty string as the separator). For example, you can do the following:

print("Hacked", password, sep="")
音盲 2025-01-27 21:56:32

此外,您还可以使用F弦来格式化输出:

print(f"Hacked{password}"

In addition, you could also use an f-string to format your output:

print(f"Hacked{password}"
铁憨憨 2025-01-27 21:56:32

有一个简单的解决方案

print("Hacked"+password)

而不是

print("Hacked",password)
#but if you just want to stick to this method,
print("Hacked",password sep= "") #this may be the solution for you.

Got a straightforward solution

print("Hacked"+password)

Instead of

print("Hacked",password)
#but if you just want to stick to this method,
print("Hacked",password sep= "") #this may be the solution for you.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文