如何使用cUrl,ssl创建目录?(How to create directory with cUrl, ssl?)
我在PHP上创建安全的FTP管理器。 我有以下内容:
curl_setopt(self::$FTP, CURLOPT_URL, "ftp://".$user.":".$pass."@".$host); curl_setopt(self::$FTP, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt(self::$FTP, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt(self::$FTP, CURLOPT_FTP_SSL, CURLFTPSSL_TRY); curl_setopt(self::$FTP, CURLOPT_FTPLISTONLY, TRUE); curl_setopt(self::$FTP, CURLOPT_RETURNTRANSFER, 0); curl_exec(self::$FTP);
没关系。 现在如何创建目录?
Im creating secure FTP manager on php. I have the following:
curl_setopt(self::$FTP, CURLOPT_URL, "ftp://".$user.":".$pass."@".$host); curl_setopt(self::$FTP, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt(self::$FTP, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt(self::$FTP, CURLOPT_FTP_SSL, CURLFTPSSL_TRY); curl_setopt(self::$FTP, CURLOPT_FTPLISTONLY, TRUE); curl_setopt(self::$FTP, CURLOPT_RETURNTRANSFER, 0); curl_exec(self::$FTP);
its ok. Now how to create directories?
原文:https://stackoverflow.com/questions/10869672
更新时间:2023-09-06 16:09
最满意答案
您需要再次迭代索引并重新分配任何不符合条件的索引:
import random SD = 7 nominalList = [1,2,3,4,5] randomList = [random.normalvariate(0, SD) for n in nominalList] for i,n in enumerate(nominalList): while n + randomList[i] < 0: randomList[i] = random.normalvariate(0, SD)
或者另一个想法,只需在原始代码中缩进:
nominalList = [1,2,3,4,5] randomList = [] for n in xrange(0, len(nominalList)): randomList.append(random.normalvariate(0, SD)) while nominalList[n] + randomList[n] < 0: randomList[n] = random.normalvariate(0, SD)
You need to iterate over the indices again and reassign any that don't meet your criteria:
import random SD = 7 nominalList = [1,2,3,4,5] randomList = [random.normalvariate(0, SD) for n in nominalList] for i,n in enumerate(nominalList): while n + randomList[i] < 0: randomList[i] = random.normalvariate(0, SD)
Or another thought, just indent the
while
in your original code:nominalList = [1,2,3,4,5] randomList = [] for n in xrange(0, len(nominalList)): randomList.append(random.normalvariate(0, SD)) while nominalList[n] + randomList[n] < 0: randomList[n] = random.normalvariate(0, SD)
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
问题在于您在此行中初始化new_list的方式: new_list = list(list_init) 你的list_init设置为'test' ,所以当你创建new_list ,它看起来像 ['t', 'e', 's', 't'] 然后,如果base_list的长度> 4,则您尝试在索引5处将元素分配给new_list ,并获取IndexError 。 您应该像这样创建new_list : new_list = [None] * len(base_list) 这样,您可以确保new_list与new ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
它被认为是糟糕的形式。 如果需要保留对列表的现有引用,请使用列表解析方法。 a = [1, 3, 5] b = a a[:] = [x + 2 for x in a] print b It's considered poor form. Use a list comprehension instead, with slice assignment if you need to retain existing references to the list. a = [1, 3, 5] b = a a[:] ...
-
考虑使用生成器而不是在迭代它时改变列表,pythonic方法是编写一个接收一个序列并产生另一个序列的函数。 您可以接受一系列行,然后根据您的替换为每个输入行生成一行或多行。 这只需要一个函数,而不是一个类。 您的“额外”变量将被保留,因为您一次只执行一次replace() 。 听起来你想要置换可用字母的组合进行替换,所以如果e和v都存在,你最终应该输出4行。 下面是一个自包含的示例,说明如何使用itertools.product来解决这个问题,因为我认为你不会像循环一样容易实现。 import iterto ...
-
什么阻止你创建一个空列表并附加到它? def extract_header_from_summary_from_report_htmltestrunner(): filename = (r"C:\temp\selenium_report\ClearCore501_Automated_GUI_TestReport.html") html_report_part = open(filename,'r') soup = BeautifulSoup(html_report_part, "htm ...
-
在这里你去! >>> for original in originList: if 'x' in original: res.append(anotherList[int(original[-1])]) #grab the index else: res.append(original) >>> res ['I', 'just', 'try', 'to', 'acomplish', 'this', 'foo', 'list'] >>> 由于所需值的索引 ...
-
我设法找出问题并修复它。 该代码示例中存在多个问题。 例如。 循环不正确,与主循环匹配的方法是非常错误的。 我必须为每个项目获取前缀和后缀,正确循环[即首先获取表格的后缀和前缀,然后基于后缀匹配,遍历像行一样的前缀],并将每个动态表格数据以后缀作为关键字和前缀+ data +后缀是包含链表的Map的值。 之后,我不得不再次通过包含列表的Map来循环,以正确地将值设置为我的实体类。 请原谅我没有再发布代码,因为方法很长,可能没什么帮助。 无论如何,如果有人想知道如何解决这个问题,请告诉我。 谢谢你的时间。 I ...
-
您需要再次迭代索引并重新分配任何不符合条件的索引: import random SD = 7 nominalList = [1,2,3,4,5] randomList = [random.normalvariate(0, SD) for n in nominalList] for i,n in enumerate(nominalList): while n + randomList[i] < 0: randomList[i] = random.normalvariate(0, S ...
-
简化你的代码,你想关心其他地方的json_data 。 def f(): for a, b, c, d in some_function('some_file.txt'): for i in range(1, 16): for x in json_data[str(i)]["commune"]: yield a, b, c, d, i, x for a, b, c, d, i, x in f(): print json ...