连接从文件/单词列表中读取的行

时间:2018-12-23 20:29:13

标签: python python-3.x

我在做一个Python问题来输入新密码,而我遇到了这个问题

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.0.RELEASE</version>
    <relativePath/>
</parent>

// anything related to databases: 

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

// I also tried version 5.1.40
<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>8.0.11</version> <!-- without this version, same results -->
</dependency>

它可以工作,但是输出将类似于

import random 
ask = input("How strong do you want your password to be? 1-3: ")
if ask == "1":f = open("wordlist1.txt", "r+")
f1 = f.readlines()
f2 = (random.choice(f1))
print(f2 + str(random.randint(1,20)))

但我想要

impulsively

1

1 个答案:

答案 0 :(得分:0)

您可能已经解决了这个问题,但这应该可以解决。

import random

 ask = input("How strong do you want your password to be? 1-3: ")
 if ask == "1":f = open("wordlist.txt", "r+")
 f1 = f.readlines()
 f2 = (random.choice(f1))
 f3 = str(random.randint(1,20))
 new_password = str(f2).strip() + str(f3).strip()
 print (new_password)

 **OUTPUTS**
 exaggerate17