Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python中如何从字符串中的特定位置(而不是通过索引)删除字符_Python_Python 3.x - Fatal编程技术网

在Python中如何从字符串中的特定位置(而不是通过索引)删除字符

在Python中如何从字符串中的特定位置(而不是通过索引)删除字符,python,python-3.x,Python,Python 3.x,所以我有这个代码: def myprogram(): import string import random import getpass inputpasswd = getpass.getpass("Password: ") passwd = ("I<3StackOverflow") if passwd == inputpasswd: qwerty = input("Type something: ") def add_str(lst): _letter

所以我有这个代码:

def myprogram():
import string
import random
import getpass

inputpasswd = getpass.getpass("Password: ")
passwd = ("I<3StackOverflow")
if passwd == inputpasswd:
    qwerty = input("Type something: ")
    def add_str(lst):
        _letters = ("1","2","3","4","5","6","7","8","9","0","q","w","e","r","t","z","u","i","o","p","a","s","d","f","g","h","j","k","l","y","x","c","v","b","n","m","!","#","$","%","&","/","(",")","=","?","*","+","_","-",";"," ")
        return [''.join(random.sample(set(_letters), 1)) + letter + ''.join(random.sample(set(_letters), 1))for letter in lst]

    print(''.join(add_str(qwerty)))
    input("")
else:
    print("Wrong password")
    input("")
def myprogram():
导入字符串
随机输入
导入getpass
inputpasswd=getpass.getpass(“密码:”)

passwd=(“我这对你有用吗?”

s="1a23a45a6"
print(s[1::3]) # aaa

这对你有用吗

s="1a23a45a6"
print(s[1::3]) # aaa

这样做:
initial\u str=random\u str[1:-1:3]
,其中random\u str是带有垃圾的字符串

这样做:
initial\u str=random\u str[1:-1:3]
,其中random\u str是带有垃圾的字符串

我不知道
中的“aaaaaaaaaaaaaaa”
是“有意义的文本”“还有,这个标题与你的问题有什么关系?是一些有用的就寝时间理论……我不认为
“aaaaaaa”
会是“有意义的文本”。还有,这个标题与你的问题有什么关系?是一些有用的就寝时间理论。。。