简体   繁体   English

我该如何进行这项工作它只是在我的代码 python 中说无效的 sintax 我正在尝试为不需要数字的帐户设置密码

[英]how do i make this work it just says invalid sintax in my code python i am trying to make a password for my accounts that doesnt require numbers

this is my code in the text.close() it says invalid sintax这是我在 text.close() 中的代码,它说无效的 sintax

import random
import string



def generate_random_string(length):
    
    letters = string.ascii_uppercase
    rand_string = ''.join(random.choice(letters) for i in range(length))
    text.write(srt(rand_string)
    text = open('password.txt', 'w')
    text.close() #error here
generate_random_string(19)


pls fix it i dont know the answer i am learning this programming language请修复它我不知道答案我正在学习这种编程语言

You forgot a closing bracket:你忘了一个右括号:

text.write(srt(rand_string)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的代码不起作用? 我需要制作一个密码生成器, - why my code doesnt work? i need to make a password generator, 如何让我的 function 处理负数? - How do I make my function work on negative numbers? 我正在尝试使用 GUI 进行快速排序,但我的代码已损坏 - I am trying to make a Quicksort with a GUI my code broke 我正在尝试通过删除索引来减少我的代码以使其更简单 - I am trying to reduce my code to make it simpler by removing the indexes 如何让我的 python 程序在某个时间间隔内只生成一次质数,而不是多次打印它们? - How do I make my python program generate the prime numbers in a certain interval just once instead of them being printed multiple times? 如何使函数“ addlevels”在我的主代码中起作用? - How Do I make the function “addlevels” work in my main code? 如何使解密代码正常工作? - How do I make my decrypt code work? 如果用户说“不”,我该如何做到这一点,以便我的代码可以返回一行 - How do I make it so my code can return to a line if the User says No 我如何使我的代码在python中的for循环中运行 - How do I make my code run in a for loop in python 如何使我的代码在python中正确循环? - How do I make my code loop properly in python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM